Hi Dave
You can avoid using the dropdowns altogether with the following code.
This works for all version of XL from 97 through to 2007, including
dealing with the List and Table objects of 2003 and 2007.
Insert 1 row above your autofilter row, and just type your root*, *root,
r?t etc in the cell above the column you want to filter.
Deleting the entry in the cell takes you back to showing all data.
For the benefit of the OP I have included instructions at the end on how
to copy this to the Worksheet code area.
The code assumes that the row number where you are going to type data is
Row 1, but you can amend to suit.
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 '<------- Change if required
rownum = Target.Row
colnum = Target.Column
If rownum <> testrow Then Exit Sub
If Target.Count > 1 Then
On Error Resume Next
Rows(testrow + 1).Select
ActiveSheet.ShowAllData
On Error GoTo 0
GoTo cleanup
End If
If Val(Application.Version) < 11 Then GoTo earlyversion
Set mylist = ActiveSheet.ListObjects
If mylist.Count Then
tblname = mylist(1).Name
End If
On Error Resume Next
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
Range(Target.Address).Activate
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
For the benefit of the OP, right click on the tab of the sheet with your
Autofiltered data, and copy the code into the large white code pane
area. Press Alt +F11 to take yourself back to the worksheet.