Hi all,
I'm trying to create a macro that auto-filters a specific column based on a selection in a drop-down.
With the script below I am able to filter based on the dropdown selection, however, it only gives me back "equal" matches. In my case, the column that needs to be filtered contains cells with multiple values. So what I need is a text filter based on "contain".
Here's how it should work:
This is the code I currently have (and works) to filter for exact matches:
I'm trying to create a macro that auto-filters a specific column based on a selection in a drop-down.
With the script below I am able to filter based on the dropdown selection, however, it only gives me back "equal" matches. In my case, the column that needs to be filtered contains cells with multiple values. So what I need is a text filter based on "contain".
Here's how it should work:
- The drop-down is in cell D3
- The table is range "D5:N300"
- The column that needs to be filtered is in cell L5
- When selecting a value in D3 (e.g. New Zealand) I want to apply an auto-filter on L5 for all cells containing "New Zealand" including cells that contain e.g. New Zealand and Australia
This is the code I currently have (and works) to filter for exact matches:
VBA Code:
Sub Filter_CellValue1()
ActiveSheet.Range("D5:N300").Autofilter field:=9, Criteria1:=Cells(3, 4).Value
End Sub