Home » excel » Multiple Filtering in Excel VBA?

Multiple Filtering in Excel VBA?

Posted by: admin March 9, 2020 Leave a comment


I’m trying to filter my data using 2 columns and 2 different filter requirements.

    ActiveSheet.AutoFilterMode = False
    ActiveSheet.Range("$K$2:$ZZ$200").AutoFilter Field:=5, Criteria1:="yes"
    ActiveSheet.Range("E:E").AutoFilter Field:=1, Criteria1:="Low"

If I filter by yes then it work and if I filter by Low it also works. However if I try and filter range K2-ZZ200 by yes and then Column E by Low it seems to hide everything.

Any ideas?

How to&Answers:

You have to use the same Range("$K$2:$ZZ$200") for both AutoFilter statements:

' Column A = Field 1
ActiveSheet.Range("$K$2:$ZZ$200").AutoFilter Field:=1, Criteria1:="yes"
' Column E = Field 5
ActiveSheet.Range("$K$2:$ZZ$200").AutoFilter Field:=5, Criteria1:="Low"

Also, you may need to set ActiveSheet.AutoFilterMode = True, but I’m not entirely sure.


Almost. Managed to do this using an array. The Range does not need to be the same by the way.

     ActiveSheet.AutoFilterMode = False
    ActiveSheet.Range("$E$2:$ZZ$200").AutoFilter Field:=nice, Criteria1:="yes"
    ActiveSheet.Range("$E$2:$ZZ$200").AutoFilter Field:=1, Criteria1:=Array( _
    "Filter 1", ""Filter 2", "On "Filter 3", ""Filter 4", ""Filter 5"), Operator:=xlFilterValues