I've sought help on this fully 4 years ago and I still can't seem to get my bloody head around this.
I've got a 1 dimensional array whose length will change depending on the population of a given range on a worksheet (think of 1 column).
I need to set a second array with 3 columns for which I would like to a). populate the first column with values from the first array, b). populate the other two columns with numbers deriving from the numbers in this first column.
So essentially I have array1 (a columnar array already populated) and array2 which I try to populate as follows (r1 below represents the length of array1)
ReDim array2(1 To 1, 1 To 3)
For i = 1 To r1
ReDim Preserve array2(1 To i, 1 To 3)
array2(i, 1) = array1(i)
array2(i, 2) = array1(i) + 2
array2(i, 3) = (array1(i)+2) ^ 2
end
But for whatever reason when I get to i = 2, I keep getting a 'Subscript out of Range' error.
Does anyone know why this would happen? Have I incorrectly initialized array2? (if so, I've tried switching the populating indices for array2, I've tried initializing it as 1 to 3, 1 to 1, etc., but all to no avail).
Any help would be tremendously appreciated.
-Pete
Bookmarks