How to use a list box to select pivot table page fields

Skysurfer

Board Regular
Joined
Apr 19, 2004
Messages
194
Hi,

Is there a way to loop through all the page fields in a pivot table and mark them true/false based on selections in a multi select list box?

I have a dynamic list box on a user form that contains all the page fields, which are dynamic. What I need is to have the pivot table fields tie to whatever selections the user makes in the list box.

Here is the test code I have for changing the page fields:

Code:
Sub Macro5()

    With ActiveSheet.PivotTables("PVT_Chart01_SeriesData").PivotFields("Product")
        .PivotItems("Bass Amps").Visible = False
        .PivotItems("Cobalt").Visible = False
        .PivotItems("GTR Amps").Visible = True
        .PivotItems("Guitar Parts").Visible = True
        .PivotItems("Guitars").Visible = True
        .PivotItems("PAs").Visible = True
        .PivotItems("Speaker Parts").Visible = True
        .PivotItems("Speakers").Visible = True
        .PivotItems("(blank)").Visible = True
    End With

End Sub

I guess for a loop (if that is what works), I need to increment both the page field number and the list box index number???

Thanks,

Lawrence
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,168,032
Messages
5,856,939
Members
431,841
Latest member
jaybeem

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
Top