Auto Filter Examples
Range("A1").AutoFilter Field:=1, Criteria1:="A*", Operator:=xlFilterValues
Range("A1").AutoFilter Field:=1, Criteria1:="<>A*", Operator:=xlFilterValues
Range("A1").AutoFilter Field:=1, Criteria1:="A?", Operator:=xlFilterValues
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="A*", Operator:=xlOr, Criteria2:="P*", Operator:=xlFilterValues
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="A*e", Operator:=xlFilterValues
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="?p*", Operator:=xlFilterValues
Sub FilterTheDataWithTheHelpOfWildCardCharacters()
'Define the worksheet
Dim Sh As Worksheet
Set Sh = ActiveWorkbook.Sheets("Sheet2")
'Filter the Data in the first column which starts with "A"
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="A*", Operator:=xlFilterValues
Sh.AutoFilterMode = False
'Filter the Data in the first column which doesn't starts with "A"
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="<>A*", Operator:=xlFilterValues
Sh.AutoFilterMode = False
'Filter three letter word which starts with "P" from the first column
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="=P??", Operator:=xlFilterValues
Sh.AutoFilterMode = False
'Filter the data in the first column which starts with either "A" or "P"
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="A*", Operator:=xlOr, Criteria2:="P*", Operator:=xlFilterValues
Sh.AutoFilterMode = False
'Filter the data in the first column which starts with "A" and ends with "E"
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="A*e", Operator:=xlFilterValues
Sh.AutoFilterMode = False
'Filter the data in the first column where "P" exists in second position of a string
Sh.Range("A1").AutoFilter Field:=1, Criteria1:="?p*", Operator:=xlFilterValues
Sh.AutoFilterMode = False
End Sub