I am trying to write a function to output the data that is in a 2D array to an empty table.
Function WriteArrayToTable(InputArray() As Variant, TableName As String, SheetName As String)
Dim MyTable As ListObject: Set MyTable = Worksheets(SheetName).ListObjects(TableName)
MyTable.DataBodyRange.Value = InputArray
End Function
However, I get an object variable not set on the second line. I've tried the various permutations of including and excluding Set and DataBodyRange.Value. When I set my watches, it can find MyTable just fine and InputArray is the appropriate size however MyTable.DataBodyRange is Nothing.