Home » excel » arrays – VBA FormulaArray range class error when the Characters are less than 255

arrays – VBA FormulaArray range class error when the Characters are less than 255

Posted by: admin May 14, 2020 Leave a comment

Questions:

The VBA .FormulaArray seems to have a problem with my range. I’ve read that it can’t handle over 255 characters, but mine is only about 108, but I could be understanding it wrong.

It gives an

Error 1004:
Unable to set FormulaArray property of the Range class.

I’ve tried leaving the formula in the table column and let it automatically populate when the table is filled with the Macro, but the problem is that the Index array table doesn’t exist yet before the Macro starts running.

Also tried leaving it as text and then changing the column to “general” but it doesn’t work. And I know it will create a problem changing it to an array formula this way as well.

This is the code I’m using:

With wsOutdated.ListObjects("Table_Outdated_Stock_Counts")
        .ListColumns("Ranging").DataBodyRange.NumberFormat = "General"
        .ListColumns("Ranging").DataBodyRange.FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"
    End With

I need the table column to populate automatically with the array formula.
It works for other columns(they are not array formulas though and only need to match a single value).

How to&Answers:

Maybe you could try:

.ListColumns("Ranging").DataBodyRange.Cells(1, 1).FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"

Instead of :

.ListColumns("Ranging").DataBodyRange.FormulaArray = "=INDEX(Table_DispoData[[Class]],MATCH([@Article]&[@Site],Table_DispoData[Article]&Table_DispoData[Site],0),1)"

and see if it works for you!

Explanation:

Your code is trying to write Array formula to multiple cells simultaneously which is not allowed.
If you try to do this in Excel then it will return an error “Multi-cell array formulas aren’t allowed in tables”.