Sub test_array()
Dim test() As Variant
Dim i As Integer
test() = Range("i1:i4")
For i = 1 To 3
ReDim Preserve test(1 To 1, UBound(test()) To UBound(test()) + i)
test(i) = "x" & i
Range("b2") = UBound(test)
Next i
Range("a1:a" & UBound(test)) = test
End Sub
Is there a way to resize the dimensions of the array (derived from range) using the keyword ReDim Preserve ..
Say I have values in Range("A1:A3") and we assigned an array to hold these values .. and at the code run time we need to extend the range to be A1:A5
Hi DebaserAssuming you can't just assign the new range to the array for some reason, you can transpose the range when assigning it so that the dimension you want to extend becomes the last dimension. You may also find it is faster to simply create a new array from the larger range and overwrite the values from the old array to the new array.
I start by sizing the array larger than I will need and then use Redim Preserve once at the end to shrink it to the actual dimensions.