Excel Pivot CHART – Printing Every Value in the Page Field Using a Macro

sk8josh

New Member
Joined
Jul 18, 2011
Messages
2
I have almost the same question as the post pasted below...except that I have a PIVOT CHART that I want to print all of the variations of based on the Report Filter selection.

I can set this up either way, with the chart embedded or as a separate tab, whichever is easier.

The other twist, I'd like to print as a PDF, which takes us out of the Excel Macro reach...

Any Help for either?

JoshExcel Pivot Table – Printing Every Value in the Page Field Using a Macro

Raj asks: I have an Excel pivot table set up with 150 different values in the page field. How can I run a macro to print each individual page? I tried recording the macro, but it hard codes the name of each page, and some of those pages may not be there from week to week.
Visual Basic makes this a snap. This macro uses the following:

  • The PageFields collection will tell you the name of the first page field in the pivot table.
  • The PivotItems collection is a list of all the items (pages) in the page field.
  • The CurrentPage property allows you to change which page is displayed in the pivot table.

Sub PrintAll() ' Find name of page field PageField1 = ActiveSheet.PivotTables("PivotTable1").PageFields(1) ' Save the name of the page field displayed when macro begins OrigPage = ActiveSheet.PivotTables("PivotTable1").PivotFields(PageField1).CurrentPage ' Determine how many pages there are in page field NumPages = ActiveSheet.PivotTables("PivotTable1").PivotFields(PageField1).PivotItems.Count For i = 1 To NumPages ThisPage = ActiveSheet.PivotTables("PivotTable1").PivotFields(PageField1).PivotItems(i) ActiveSheet.PivotTables("PivotTable1").PivotFields(PageField1).CurrentPage = ThisPage ActiveWindow.SelectedSheets.PrintOut Next i ' Print the (all) page ActiveSheet.PivotTables("PivotTable1").PivotFields(PageField1).CurrentPage = "(all)" ActiveWindow.SelectedSheets.PrintOut ' Restore view back to original page ActiveSheet.PivotTables("PivotTable1").PivotFields(PageField1).CurrentPage = OrigPage End Sub </pre>
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,224,616
Messages
6,179,908
Members
452,949
Latest member
beartooth91

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