I'm using VB in Excel. Trying to use an array, the size of which is set with a variables. For example:
Dim intNumRows As Integer
intNumRows = 10
Dim strCellNumber(intNumRows) As String
When I run it, it throws an error, wanting the index to be a constant.
When I replace the variable intNumRows with a number (constant) it works. This is quite a limitation to not be able to size the array while running.
What am I missing?
I am using this strCellNumber array variable to put numeric values into specific cells using For Next loops. For instance:
For intRowCounter = 1 To 5
strCellNumber(intRowCounter) = "C" & CStr(intRowCounter)
Range(strCellNumber(intRowCounter)).Value = intRowCounter * 2
This is in a Click event, if it matters. I want the user to define the size of the array. I'm thinking that maybe I can define the index constant by getting the index value from a particular cell that user puts a value in.
Years past, I did a lot of Microsoft BasicA programming. Just getting started with VB.
Thanks in advance for any help.