I'm trying to filter data based on a user's selection. The user may select more than one criteria.
I have a column called "PRODUCTS" containing a number of values (e.g., PRODUCT 1, PRODUCT 2, etc.).
I have 11 checkboxes (on the sheet itself, not a userform), each representing a product in that column. When the user checks the box for "PRODUCT 1", the data should filter accordingly.
But if they then select "PRODUCT 4" and then "PRODUCT 6", then the data should be filtered on all 3 selections.
I recorded a macro to have something to work with:
I then copied it and changed the criteria:
But whenever I execute that code, it only filters on the last product, which in the example above is "PRODUCT 4".
I think I need some sort of loop, but I'm still getting a grasp on that.
Any suggestions would be much appreciated.
I have a column called "PRODUCTS" containing a number of values (e.g., PRODUCT 1, PRODUCT 2, etc.).
I have 11 checkboxes (on the sheet itself, not a userform), each representing a product in that column. When the user checks the box for "PRODUCT 1", the data should filter accordingly.
But if they then select "PRODUCT 4" and then "PRODUCT 6", then the data should be filtered on all 3 selections.
I recorded a macro to have something to work with:
Code:
ActiveSheet.Range("$B$9:$N$193").AutoFilter Field:=1, Criteria1:=Array("PRODUCT 1"), Operator:=xlFilterValues
I then copied it and changed the criteria:
Code:
Sub filteronproduct()[INDENT]ActiveSheet.Range("$B$9:$N$193").AutoFilter Field:=1, Criteria1:=Array("PRODUCT 1"), Operator:=xlFilterValues[/INDENT]
[INDENT]ActiveSheet.Range("$B$9:$N$193").AutoFilter Field:=1, Criteria1:=Array("PRODUCT 2"), Operator:=xlFilterValues
ActiveSheet.Range("$B$9:$N$193").AutoFilter Field:=1, Criteria1:=Array("PRODUCT 3"), Operator:=xlFilterValues
ActiveSheet.Range("$B$9:$N$193").AutoFilter Field:=1, Criteria1:=Array("PRODUCT 4"), Operator:=xlFilterValues
[/INDENT]
End Sub
But whenever I execute that code, it only filters on the last product, which in the example above is "PRODUCT 4".
I think I need some sort of loop, but I'm still getting a grasp on that.
Any suggestions would be much appreciated.