Multi Dimensional Array
Hi Andy,
Try this
Option Base 1
Public Sub Populate_2D_Array()
Dim My2DArray() As Variant
Dim I As Integer
Dim J As Integer
Dim K As Integer
For I = 1 To 100
If ActiveSheet.Cells(I, 1).Value = 10 Then
K = K + 1
ReDim Preserve My2DArray(K, 3)
For J = 1 To 3
My2DArray(K, J) = ActiveSheet.Cells(I, J).Value
Next J
End If
Next I
MsgBox UBound(My2DArray, 1)
MsgBox My2DArray(UBound(My2DArray), 3)
End Sub
The last two line are just to let you know the size of it first
dimension, then the value of the last element for both dimensions ie
last row and last column.
Ken Johnson
|