tiredofit
Well-known Member
- Joined
- Apr 11, 2013
- Messages
- 1,825
- Office Version
- 365
- 2019
- Platform
- Windows
I am trying to use the Filter function but get an error.
the error message is:
Is it because DataArray needs to be a String instead of a Variant?
I tried this but it still failed:
with the same error message as before.
Can someone please tell me what is wrong?
Thanks
Code:
Dim rng As Range
Set rng = Sheet1.Range("A1:A100")
Dim DataArray() As Variant
DataArray = rng
Dim Output As Variant
Output = Filter(DataArray(), "Apples", True)
the error message is:
Code:
Run-time error '13'
Type mismatch
Is it because DataArray needs to be a String instead of a Variant?
I tried this but it still failed:
Code:
Dim rng As Range
Set rng = Sheet1.Range("A1:A100")
Dim DataArray() As Variant
DataArray = rng
Dim OutputArray() As String
ReDim OutputArray(1 To 100, 1 To 1) As String
Dim i As Integer
For i = 1 To 100
OutputArray(i, 1) = DataArray(i, 1)
Next i
Dim Output As Variant
Output = Filter(OutputArray(), "Apples", True)
with the same error message as before.
Can someone please tell me what is wrong?
Thanks