A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
You could add a data validation list to another cell, and use that cell and the the worksheet's change event to apply the filter to the data set.
For this technique to work, you need to shift your table down on the sheet so that the control cell stays visible.
If your table starts in A3 with headers in row 3 and you want to filter based on column A, then add the Data Validation list to cell A1 with the list of values in the order that you want, then:
- Copy this code.
- Right-Click the sheet tab of interest.
- Select "View Code"
- Paste the code into the window that appears.
- Save the file as a macro-enabled .xlsm file.
- Make changes as needed
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then
With Range("A3").CurrentRegion
.AutoFilter Field:=1, Criteria1:=Target.Value
End With
End If
End Sub