Hi
I want to create variable length array which should bring different data at each condition.
My code is
Sub Test()
Dim r As Integer
Dim c As Integer
r = Application.WorksheetFunction.CountIf(Range("A1", Range("A1").End(xlDown)), Cells(1, 10))
c = Range("A1", Range("A1").End(xlToRight)).Columns.Count
ReDim temparray(1 To r, 1 To c)
For ar = 1 To r
For ac = 1 To c
For i = 1 To Range("A5", Range("A5").End(xlDown)).Rows.Count
If Cells(1, 10) = Cells(i, 1) Then
temparray(ar, ac) = Cells(i, ac)
End If
Next i
Next ac
Next ar
Range(Cells(1, 6), Cells(r, 5 + c)) = temparray
End Sub
But I could not understand at which part I did mistake, because code brings data only one of criteria. Please correct me. I want to understand the code.
Thank you in advance
Bookmarks