I want to autofilter based on criteria that is not equal to what I select, can someone help me with the syntax, my code reads as follows, basically I have a combobox that has a list of numbers, if the user chooses one of those numbers, I want this code to work and filter sheet 3, row 3, column 3 on all values except the one teh user chooses, this way I can then have code to delete visible cells. This not equal to is not working, it seems easy to filter on a value but not vice versa, I tried the macro recorder and it seemed that quotes were needed, so I tried to add quotes around my value to see whether that would make a difference. Appreciate any insights!
Code:
Private Sub Select_Terr(sTerr As String)
On Error Resume Next
Dim sterr1 As String
Dim addq As String
addq = """"
sterr1 = addq & "<>" & sTerr & addq
Worksheets(3).Activate
ActiveSheet.ShowAllData
With ActiveWorkbook.Sheets(3)
If sTerr <> "All" Then
.Rows("3:3").Select
Selection.AutoFilter Field:=3, Criteria1:=sterr1, Operator:=xlAnd
End If
End With
On Error GoTo 0
Worksheets(1).Activate
End Sub