Hi all
Im trying to figure out how i can set the max value of an array from a value obtained from another source, like the number of rows in a range for example
This is for future projects when i will need to work in arrays ,and arrays that will be changing size depending on a given range
but it keeps telling me i must have a constant, and when i try to set it as a constant , its says no you cant do that
Any ideas how to get around this.
Ive worked in matlab a lot and im trying to see if i can switch to VBA
as always any help is much appreciated
Best,
J
Im trying to figure out how i can set the max value of an array from a value obtained from another source, like the number of rows in a range for example
Code:
Public Sub test()
'Const x = 12
Range("e12").Select
nld = Range(Selection, Selection.End(xlUp)).Rows.Count
y = nld
Const x = y
MsgBox nld
Dim myarr(1 To x) As Variant
For I = 1 To nld
myarr(I) = Cells(12 + I, 5).Value
Cells(I, 7).Value = myarr(I)
Next I
End Sub
This is for future projects when i will need to work in arrays ,and arrays that will be changing size depending on a given range
but it keeps telling me i must have a constant, and when i try to set it as a constant , its says no you cant do that
Any ideas how to get around this.
Ive worked in matlab a lot and im trying to see if i can switch to VBA
as always any help is much appreciated
Best,
J