I have a Table, with 144 columns, consisting of strings that I convert to Formulas in another Table. Work around for Volatile function Indirect when I add and remove Sheets, but need the Formula NOT to go #REF....
SO - I have an 1 dim array and would need each data to be written/saved in a new row/record in a Listobject Table.
I have a working solution - but it's slow - I copy each value from the array to each cell in the table, with a "for next" loop:
I am looking for a way to instead work with an Array. Creating the Array and then copy the whole array in one line to the Table, into a new row. I was thinking in the lines of:
But I'm missing how to Add the new row, with each element in the Array being copied to a cell in the new row.
OBS: Im using another Table with a generic "Formula" and creates new rows with functioning formulas in the new table. Thats why im using .Formula.
SO - I have an 1 dim array and would need each data to be written/saved in a new row/record in a Listobject Table.
I have a working solution - but it's slow - I copy each value from the array to each cell in the table, with a "for next" loop:
VBA Code:
Dim MyTable As ListObject
Set MyTable = Ws.ListObjects("TestTbl")
Dim NewRow As ListRow
Set NewRow = MyTable.ListRows.Add(AlwaysInsert:=True)
For i = 1 To MyTable.ListColumns.Count
If Len(myArr(rowToCopy(s), i)) > 0 Then
On Error Resume Next
NewRow.Range(i).Formula = "=" & Replace(myArr(rowToCopy(s), i), "xxx", "SheetName")
On Error GoTo 0
Else
NewRow.Range(i).Formula = "=" & "#N/A"
End If
Next i
I am looking for a way to instead work with an Array. Creating the Array and then copy the whole array in one line to the Table, into a new row. I was thinking in the lines of:
Code:
dim valueArray(1 to 144) as String
for i = 1 to 144
If Len(myArr(rowToCopy(s), i)) > 0 Then
On Error Resume Next
valueArray(i).Formula = "=" & Replace(myArr(rowToCopy(s), i), "xxx", "SheetName")
On Error GoTo 0
Else
valueArray(i).Formula = "=" & "#N/A"
End If
next i
But I'm missing how to Add the new row, with each element in the Array being copied to a cell in the new row.
OBS: Im using another Table with a generic "Formula" and creates new rows with functioning formulas in the new table. Thats why im using .Formula.