Pivot Table Filter by Specific Criteria

Bench

Board Regular
Joined
Aug 27, 2009
Messages
134
Hi,

I'm trying to write a part within a macro which will filter down a Pivot Table to show 4 or 5 choices particular to the user from a list of around 30.

When i've recorded this it shows it the opposite way as below, ie. visible = false, i've tried doing it the opposite way and put visible=true unfortunately this didn't work.

To add to the conundrum, the list won't always be exhaustive, so i may want David Broad to show, how can i make i work if he's not in the list??

Any ideas would be appreciated. Thanks

Code:
Sub Macro18()
'
' Macro18 Macro
'
'
    With ActiveSheet.PivotTables("PivotTable2").PivotFields("Surveyor")
        .PivotItems("Adam Baker").Visible = False
        .PivotItems("Alexandra Beeching").Visible = False
        .PivotItems("Dominic Jay").Visible = False
        .PivotItems("Gary Sumpter").Visible = False
        .PivotItems("Gary Waring").Visible = False
    End With
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

Forum statistics

Threads
1,223,246
Messages
6,170,987
Members
452,373
Latest member
TimReeks

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