With Excel VBA macros, I am building a excel table (listobject) which contains several data columns (with values in them) and one column with formulas. These formulas are different for every line. These formulas are constructed and stored in an array by vba and only put in the table column once at the end. This is necessary for speed issue.
My problem is that the resulting formulas stored in the column are all identical. They are the one from the first element of the array.
Notes:
- The "AutoFillFormulasInLists" is set to FALSE.
- If I try to store values instead of formulas, everything works fine.
- If I try to do the same logic but put the formulas in a simple cell range, everything works fine.
Here is a very simplified example of the code i'm using to pupulate the column of the table with formulas:
Dim sformulas(1 To 3) As String
sformulas(1) = "=""x"""
sformulas(2) = "=""y"""
sformulas(3) = "=""z"""
ActiveSheet.ListObjects("Table1").ListColumns("ColumnX").DataBodyRange.Formula = Application.Transpose(sformulas)
The resulting formula in ColumnX are all ="x"
But I would expect to have ="x", ="y" and ="z"
Is there any way to storing the proper formula in the table?