Hi Guys,
i have array and want to output to each listcolumn in listtable object.
code:
Sub test()
Dim arrVar(0 To 2, 0 To 1) As Variant
Dim lstTable As ListObject
Dim i As Long
Set lstTable = ActiveSheet.ListObjects(1)
arrVar(0, 0) = 1
arrVar(0, 1) = 2
arrVar(1, 0) = "Paul"
arrVar(1, 1) = "Luke"
arrVar(2, 0) = "Magaj"
arrVar(2, 1) = "Skywalker"
For i = 1 To lstTable.ListColumns.Count
If i = 1 or i = 3 then
lstTable.ListColumns(i).DataBodyRange.Value = Application.Index(arrVar, 0, 1) '''here i am getting not proper data
end if
Next i
End Sub
in line i can not handle outputting array:
lstTable.ListColumns(i).DataBodyRange.Value = Application.Index(arrVar, 0, 1)
I have to have array in this shape because it is taken from recordset rows (rst.getrows property).
I could populate recordset at once but sometimes i have to skip columns. So for example output only to column 1 and 3.
Can anybody help?
Best wishes,
Jacek Antek
Bookmarks