I have been looking for a code to filter criteria out of a list I do not want. I have a code that works for filtering criteria I do want but when I try to reverse it, I get a "mismatch" error.
Here is my code for filtering out criteria I do not want.
Sub Filters()
Dim IntP As Worksheet 'sheet where the main table is
Dim Param As Worksheet 'sheet where my parameters are
Dim iRange As Range 'the range of my table
Dim range1 As Range 'the range that contains the list I want to filter in iRange
Set IntP = Worksheets("Internet Promotions")
Set Param = Worksheets("Sheet1")
Set iRange = IntP.Range("A1", ("AU" & IntP.Range("A" & Rows.Count).End(xlUp).Row)) 'range of my table
Set range1 = Param.Range("D2", ("D" & Param.Range("D" & Rows.Count).End(xlUp).Row)) 'range of my paramters
Dim var1 As Variant
Dim sArray() As String
Dim i As Long
'---------------Filter-----------------------
var1 = range1.Value
ReDim sArray(1 To UBound(var1))
For i = 1 To (UBound(var1))
sArray(i) = var1(i, 1)
Next
iRange.AutoFilter Field:=21, Criteria1:="<>" & sArray, Operator:=xlFilterValues
End Sub
I do not understand why this is not working.
Any help would be greatly appreciated.