magemaester
New Member
- Joined
- Dec 17, 2017
- Messages
- 10
Hi guys,
I have a piece of code which requires using the FILTER Function, however the SourceArray argument is giving me a Type mismatch error, any help would be greatly appreciated.
This doesn't work
This works
So just from these two examples I guessed that the error is either because
1) ReDim arrList2(1 to 1559, 1) makes this essentially a 2D array which isn't permitted by the SourceArray argument, or
2) Using the arrList2 = Range("A2:A1560").Values turns whatever string I had in the original cells into Numbers, which is also not permitted by the SourceArray
Regarding 1), if I change the ReDim statement to ReDim arrList2(1 to 1559), it still doesn't work. So this just leaves possibility 2), which I don't know how to fix.
If anyone can offer a solution that would be really appreciated. Thanks!!
I have a piece of code which requires using the FILTER Function, however the SourceArray argument is giving me a Type mismatch error, any help would be greatly appreciated.
This doesn't work
Code:
Dim bDistinct as Boolean
Dim arrList2() Variant
Redim arrList2(1 to 1559, 1)
arrList2 = Range("A2:A1560").Values
bDistinct = UBound(Filter(SourceArray:=arrList2, Match:="banana", Include:=True, Compare:=vbBinaryCompare)) < 0
This works
Code:
Dim bDistinct as Boolean
Dim arrList2() Variant
Redim arrList2(1)
bDistinct = UBound(Filter(SourceArray:=arrList2, Match:="banana", Include:=True, Compare:=vbBinaryCompare)) < 0
So just from these two examples I guessed that the error is either because
1) ReDim arrList2(1 to 1559, 1) makes this essentially a 2D array which isn't permitted by the SourceArray argument, or
2) Using the arrList2 = Range("A2:A1560").Values turns whatever string I had in the original cells into Numbers, which is also not permitted by the SourceArray
Regarding 1), if I change the ReDim statement to ReDim arrList2(1 to 1559), it still doesn't work. So this just leaves possibility 2), which I don't know how to fix.
If anyone can offer a solution that would be really appreciated. Thanks!!