Is it possible to name an array variable using a different variable? For example, if I define variable \"i\" as an integer with a value equal to the number of columns I\'ve use
You can create an array of arrays (though your question is a little unclear..)
Sub MyArrays()
Dim arrays()
Dim arr
Dim i, j
i = 5 'e.g.
ReDim arrays(1 To i)
For j = 1 To i
arr = Array()
ReDim arr(1 To j)
arrays(j) = arr
Next j
'reference an array by its position in "arrays"
Debug.Print UBound(arrays(3))
End Sub
Yes.
Dim i(5) As Integer
In VBA you can then access elements from i(0)
to i(5)
.
Based on your edited question, the answer is no. You must explicitly define each variable in your code.
The other option would be to write code that writes your code - a form of code generation. Effectively that lets you write very long and complex code by repeating code "templates". But I don't think this would help in your case.