I'm experimenting with filtering arrays. I have 2 codes, one works if you hard code in array:
Sub Test_01()
Dim varTest() As Variant
10 varTest = Array("James", "Richard", "Eric", "Mike")
Dim fltTest As Variant
20 fltTest = Filter(varTest, "r", True)
30 MsgBox Join(fltTest, vbCr)
End Sub
I get Richard and Eric.
but the other doesn't work if you use try to pick up the array from the worksheet in range A1 to A4:
James
Richard
Eric
Mike
Sub Test_02()
Dim varTest() As Variant
10 varTest = Array(Range("A1:A4"))
Dim fltTest As Variant
20 fltTest = Filter(varTest, "r", True)
30 MsgBox Join(fltTest, vbCr)
End Sub
I get run-time error 13;
Type mismatch
at line 30
I couldn't find an information online to modify Sub Test_02() work.
Does anyone know how to modify the second code to make it work?
Thanks,
Xrull
Bookmarks