P
Peter Bernadyne
I thought I had this down, but I must be forgetting something because
the following code does not work.
I have a range of values in a worksheet which I am trying to read into
an array. My loop is as follows:
Dim myarray() as Double
Range("A1").Select 'Note: assume data is in A1:A500
For i = 1 to 500
number_i = ActiveCell.Value
ReDim Preserve myarray(1 to i)
myarray(i) = number_i
ActiveCell.Offset(i,0).Select
Next
However, this results in a). myarray not expanding at all (dont' know
if values are overwritten or what) and b). The loop appears to execute
in increments which are the length of each re-sized length of myarray
at each iteration instead of the regular steps of '1'.
Does anyone know what I am doing wrong here?
Thanks in advance for any kind help.
the following code does not work.
I have a range of values in a worksheet which I am trying to read into
an array. My loop is as follows:
Dim myarray() as Double
Range("A1").Select 'Note: assume data is in A1:A500
For i = 1 to 500
number_i = ActiveCell.Value
ReDim Preserve myarray(1 to i)
myarray(i) = number_i
ActiveCell.Offset(i,0).Select
Next
However, this results in a). myarray not expanding at all (dont' know
if values are overwritten or what) and b). The loop appears to execute
in increments which are the length of each re-sized length of myarray
at each iteration instead of the regular steps of '1'.
Does anyone know what I am doing wrong here?
Thanks in advance for any kind help.