Help Cycling Through Each Page in a Pivot

dem1an

Board Regular
Joined
Jun 3, 2008
Messages
70
I'm setting up some code that will peform a series of calculations off a pivot table. I want the code to cycle through all the pages in the pivot table. I've indexed the pages (1 to X), but there may be instances where there may be numbers missing. It will mess up my calculations if I try to go to pivot on a page that does not exist.

This is how I would change the page 9 in VBA

Code:
    AvgCost.PivotTables("AvgCost").PivotFields("Period").CurrentPage = "9"
    Call PeformCalculations

This is my feeble attempt to cycle through all the Pages and where I need hep! I really have no clue. =)

Code:
    Dim PivotSheet As Sheets
 
    With AvgCost.PivotTables("AvgCost").PivotFields("Period")
        .ManualUpdate = True
        For Each PivotSheet In AvgCost.PivotTables("AvgCost").PivotFields("Period")
 
            Call PeformCalculations
 
        Next PivotSheet
        .ManualUpdate = False
    End With
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Correction I should have said PivotPage rather than PivotSheet, nevertheless, you get the idea of what I'm trying to achieve. Thanks!
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,135
Members
452,890
Latest member
Nikhil Ramesh

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