How can I filter a multidimensional array?
My code does neither work nor does it seem neat:
Option Explicit
Sub CalcE()
Dim TotalRows As Long
Dim myArray, myArray2 As Variant
Dim i, a As Integer
Populate Array
TotalRows = Sheets("Data").Rows(Rows.Count).End(xlUp).Row
myArray = Sheets("Data").Range("A5:F" & TotalRows)
MsgBox "Array populated with " & UBound(myArray) & "entries."
Filter myArray entries into myArray2, but only the column 1, 4 and 6.
a = 0
For i = 0 To UBound(myArray)
If myArray(i, 1) > 1 Then
myArray2(a, 1) = myArray(i, 1)
myArray2(a, 2) = myArray(i, 4)
myArray2(a, 3) = myArray(i, 6)
a = a + 1
End If
Next i
MsgBox "Array populated now with " & UBound(myArray2) & "entries."
End Sub
I googled and figured that arrays in Excel seem to be very inflexible things, not nice to work with. People usually give up on VBA Arrays and use AutoFilter methods instead. I wounder whether there really isn't a good way. It would be so neat to have!