When you add a field to the Row Label or Column Label area of the pivot table, its heading cell shows a drop down arrow. When you click the arrow, you’ll see Sort and Filter options, for the selected field.
In the screen shot below, you can see the sort and filter options for the Product field, and the check boxes for manually filtering the list.
Hide the Arrows
If you want to prevent manual filtering, you can hide the drop down arrows, by using a bit of Excel VBA programming.
The following code will hide the drop down arrow for every field in the first pivot table on the active worksheet.
Sub DisableSelection() Dim pt As PivotTable Dim pf As PivotField Set pt = ActiveSheet.PivotTables(1) For Each pf In pt.PivotFields pf.EnableItemSelection = False Next End Sub
Sorting and Filtering Still Available
After you hide the arrows, you will still be able to sort the pivot items, by using the commands on the Ribbon.
You’ll also be able to use the Label Filters and Value Filters, if you right-click on an item in the disabled field.
Show the Arrows
After you hide the arrows, you can use similar code to show them again — just change the EnableItemSelection setting to True.
The following code will show the drop down arrow for every field in the first pivot table on the active worksheet.
Sub EnableSelection() Dim pt As PivotTable Dim pf As PivotField Set pt = ActiveSheet.PivotTables(1) For Each pf In pt.PivotFields pf.EnableItemSelection = True Next End Sub
Video: Apply Multiple Filters to Pivot Field
To see the different types of filters – label, value and manual – please watch this short video tutorial.
Or watch on YouTube: Apply Multiple Filters to Pivot Table Field
________________
Hi!
I tried copy / paste the VBA code for hiding dropdown arrows; it worked for some fields but not all of them?
I pasted the code onto the ‘Generak Section’for my worksheet. Is that correct?
Many thanks in advance
Amelie
Make sure to save your file as a MACRO file.
After you save, you run the VBA code and it should work 🙂
I used the coding to hide the drop down arrows. May I know how to let the drop down arrow show up? Thank you!
@Bo, thanks for asking, and I’ve added some sample code that turns the arrows back on.
How would one modify the code to remove the flags on whichever is the active pivot table, or for all pivot tables in a workbook? Can I use the pivot table name somewhere in the code?
Thank you