Search code examples
excelvbaexcel-2007

Macro button to change filter


I want to have buttons to change my excel filter.

I filter my fields with contains=something so each button should change that something text.

Button1: change filter to contains=button1

Button2: change filter to contains=button2

and so on..


Solution

  • Since I found answer myself, I put it here for future help.

        Sub AI()
    
        '            sheet range and which field you want to filter and criteria to search
            ActiveSheet.Range("$A$2:$Z$203").AutoFilter Field:=14, Criteria1:="stringtomatch"
        End Sub