I'm having a problem populating an array. For some reason all of the tutorials I can find would rather list the data & sizing explicitly in the code itself (which sort of defeats the purpose of using VBA to begin with for this task).
My question is about how to dynamically size an array, if it's even possible to do so in the manner that I'm trying to. The code itself is commented with the background and specific questions.
When I run the code I get an "Application-defined or object-defined error" (1004)
Also, using a for... next loop to populate the arrays may end up being computationally inefficient as the datasets typically average 23k rows
Code:
Sub DCList()
ReDim DCList(0, 0)
Dim cnum As Integer
' count the number of columns that have been used in the workbook
cnum = ActiveWorkbook.Sheets("data").UsedRange.Columns.Count
' set array dimensions to 1 row & Cnum columns
ReDim DCList(1, cnum)
' set array values to values found in the range (A1, cnum 1)
DCList = ActiveWorkbook.Sheets("data").Range(Cells(1, 1), Cells(1, cnum)).Value
'Other info:
' DCList is a global variable set as Variant type
' The overarching goal of this sub is purely to determine the column names of
' a dataset so that (in another sub) the user can select which column to lookup
End Sub