Multi Dimensional Array
Hi Andy,
This version places the array values onto the worksheet starting at G1.
Just change the G1 to suit your needs...
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(3, K)
For J = 1 To 3
My2DArray(J, K) = ActiveSheet.Cells(I, J).Value
Next J
End If
Next I
ActiveSheet.Range("G1").Resize(UBound(My2DArray, 2), _
UBound(My2DArray, 1)) = WorksheetFunction.Transpose(My2DArray)
End Sub
Ken Johnson
|