Problem with Alan Beban's ResizeArray
Hi RB,
I'm not sure what your code looks like, but with 1 through 12 in A1:C4 I
ran the following
Option Base 1
Public SuppliedArray() As Variant
_________________________________
Sub TestArrayFill()
ReDim SuppliedArray(1 To 4, 1 To 3)
Set rng = Sheets(4).Range("A1:C4")
For i = 1 To 4
For j = 1 To 3
SuppliedArray(i, j) = rng(i, j)
Next
Next
ResizeArray SuppliedArray, 5, 3
For i = 1 To 5: For j = 1 To 3
Debug.Print SuppliedArray(i, j)'<-returned 1 thru 12 plus 3 blanks
Next
Next
Debug.Print UBound(SuppliedArray)'<-returned 5
End Sub
Where are we not running the same thing?
Alan Beban
RB Smissaert wrote:
Trying to use Alan Beban's Sub ResizeArray, but I can't get it to work.
There are no errors, but the final array after resizing has all empty
elements.
It goes wrong at the final bit where the altered array is assigned to the
supplied array:
MsgBox arr1(1, 2)
'goes wrong here
MyArray = arr1
MsgBox MyArray(1, 2)
MsgBox SuppliedArray(1, 2)
The first 2 messageboxes give the right value, but the third gives a blank.
The array supplied to the sub is a 2-dimensional 1-based publicly declared
variant array.
I must be making a simple mistake, but I can't see it.
Thanks for any advice.
RBS
|