PDA

View Full Version : VBA Dynamic array



cblake843
11-29-2018, 04:05 AM
I'm having a nightmare simply trying to define a dynamic array and write data to it.

Basically I have the following :-

Where y is already defined as the function and updates as the function is called. I want to add the y value to an array so I can fix the max value of y when the function reaches the end i.e. no more updates.

y As Integer,


Dim Arr1() as variant

Arr1() = y



Doesn't work , saying compile error can't assign to an array.

Any suggestions ?

Paul_Hossler
11-29-2018, 07:53 AM
Dim Arr1() as Variant is a dynamic array, i.e. no upper/lower bounds yet

Also, you can't assign a variable to an array





Dim Arr1() as Variant

ReDIm Arr1(0 to 99)

Arr1(27) = y




No other ideas without know more about what is going on

More information will get better ideas