How to Use Slicers With Excel Advanced Filter (2024)

Add Criteria Settings

In the All column, for each field that has a Slicer, type the criteria setting that you want to use if the Slicer is cleared, and the pivot table filter shows "(All)".

For the text fields, I entered an asterisk, and for the number fields I used ">0". You could use different criteria, based on your data.

How to Use Slicers With Excel Advanced Filter (1)

Get the "All" Criteria

Below the Criteria range, another set of formulas will get the criteria setting from our table, for cases when "All" is selected. The formula uses the INDEX and MATCH functions to pull the values from the Field List table.

Enter the following formula in cell D7, and copy it across to F7

=INDEX(tblHead[[All]:[All]],MATCH(D3,HeadingsList,0))

The formula looks for the field name in cell D3, and finds its match in the HeadingsList range. Then, it returns the value from the All column in that row.

How to Use Slicers With Excel Advanced Filter (2)

Add the Criteria Formulas

Next, we'll add formulas in the criteria row, to use with the Advanced Filter. Each formula is slightly different, and refers to its field name and value in the pivot table filters. The formula checks the field in the source data, to see if the selected item appears.

  • If the item is found in the source data, that item is used as the criterion.
  • If the item isn't found, e.g. (All) or (Multiple Items), the alternate criterion is used.

Enter the following formula in cell D4:

=IF(COUNTIF(INDIRECT("Sales_Data[" & A3 & "]"),B3),B3,D7)

Enter the following formula in cell E4:

=IF(COUNTIF(INDIRECT("Sales_Data[" & A4 & "]"),B4),B4,E7)

Enter the following formula in cell F4:

=IF(COUNTIF(INDIRECT("Sales_Data[" & A5 & "]"),B5),B5,F7)

Here's the result, if none of the Slicers are cleared. I've used grey fill on all the cells with formulas. The Advanced Filter would return all the records in the Sales_Data table

How to Use Slicers With Excel Advanced Filter (3)

Here's the result, after selections are made in the Category and Orderyr Slicers. The Advanced Filter would return all the records for Snacks sales in 2016, for any Region.

How to Use Slicers With Excel Advanced Filter (4)

Add the Macro Code

Next, you'll add the macro -- GetDataForSlicersSel -- that runs an Advanced Filter. Add the following code to a regular module in the workbook:

How to Use Slicers With Excel Advanced Filter (2024)
Top Articles
Latest Posts
Article information

Author: Delena Feil

Last Updated:

Views: 6187

Rating: 4.4 / 5 (65 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Delena Feil

Birthday: 1998-08-29

Address: 747 Lubowitz Run, Sidmouth, HI 90646-5543

Phone: +99513241752844

Job: Design Supervisor

Hobby: Digital arts, Lacemaking, Air sports, Running, Scouting, Shooting, Puzzles

Introduction: My name is Delena Feil, I am a clean, splendid, calm, fancy, jolly, bright, faithful person who loves writing and wants to share my knowledge and understanding with you.