Filtering PivotTable results based on a list on another worksheet

glitch

New Member
Joined
May 16, 2011
Messages
4
First of all, I am relatively new at using Excel for work, so I am sorry if my question is very basic.

I'm working with data that includes a dozen or so items that shouldn't be part of the PivotTable calculation. I would like to have to avoid checking/unchecking the items in the filter field every time I analyze another version of the data. What's the best way of going about it?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Welcome aboard the Board!

Here's a quick and dirty solution. Remember, if there are no values left, you're going to get an error, so you might want to check for that first.

I set up Exclude_These as a Named Range on a different sheet.
Enter the correct Sheet Name, Table Name, and Field Name.
Run this from a button or have it fire on on any PivotTable event of your choice, and voila!

Code:
Sub ExclFromList()
    Dim PField As PivotField
    Set PField = Worksheets("Sheet Name").PivotTables("Table Name").PivotFields("Field Name")
    Dim ExclItem As Range
 
    Application.ScreenUpdating = False
    With PField
        For Each ExclItem In [Exclude_These]
            .PivotItems(ExclItem.Value).Visible = False
        Next ExclItem
    End With
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,331
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top