Hi Jeff
If your Autofilter is in row 1, insert a new blank row at row 1.
Copy the following code, then right click the sheet Tab>View code>Paste
Now enter any value in row 1 of the relevant column, and the data will be
filtered by that value.
e.g. cat* will filter on anything beginning with cat. *cat* will filter by
anything containing cat. c?t* will find anything beginning with cat, cit,
cot, cut
All of the numeric operators work for columns with numeric data.
The advantage is that the filtered column is highlighted, and it shows what
you have filtered that column on.
deleting an entry in row 1 for any column, removes the filter for that
column
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rownum As Long, colnum As Long
Dim tblname As String, mylist As Object
'Set this next value to the row number above your filter
Const testrow = 1
rownum = Target.Row
colnum = Target.Column
On Error Resume Next
If Target.Count > 1 Then
Rows(testrow + 1).Select
ActiveSheet.ShowAllData
GoTo cleanup
End If
If rownum <> testrow Then GoTo cleanup
If Val(Application.Version) < 11 Then GoTo earlyversion
Set mylist = ActiveSheet.ListObjects
If mylist.Count Then
tblname = mylist(1).Name
End If
If Cells(rownum, colnum).Value = "" Then
If mylist.Count Then
mylist(tblname).Range.AutoFilter Field:=colnum
GoTo cleanup
End If
Selection.AutoFilter Field:=colnum
Else
If mylist.Count Then
mylist(tblname).Range.AutoFilter Field:=colnum, _
Criteria1:=Cells(rownum, colnum).Value
GoTo cleanup
End If
Selection.AutoFilter Field:=colnum, _
Criteria1:=Cells(rownum, colnum).Value
End If
GoTo cleanup
earlyversion:
If Cells(rownum, colnum).Value = "" Then
Selection.AutoFilter Field:=colnum
Else
Selection.AutoFilter Field:=colnum, _
Criteria1:=Cells(rownum, colnum).Value
End If
cleanup:
Range(Target.Address).Activate
On Error GoTo 0
End Sub