Macro for pivot table and printing.....

  • Thread starter Thread starter JC
  • Start date Start date
J

JC

I tried to set up a macro procedure for printing a pivot table. My
situation is this, I already set up a pivot table with different
location numbers and other pertinent info. I want to print a single
page for each location. As you know , if I do it manually, I have to
select each location from the list one at a time and print each one. I
just want to know if a macro procedure can be done on this operation.
So that I do not have to select any location and Macro will do the
work for me. Thanks.
 
The following code will print the pivot table for each item in the page
field:

'=======================
Sub PrintPivotPages()
'prints a copy of pivot table for
'each item in page field
'assumes one page field exists
On Error Resume Next
Dim pt As PivotTable
Dim pf As PivotField
Dim pi As PivotItem
Set pt = ActiveSheet.PivotTables.Item(1)
For Each pf In pt.PageFields
For Each pi In pf.PivotItems
pt.PivotFields(pf.Name).CurrentPage = pi.Name
' ActiveSheet.PrintOut 'use this for printing
ActiveSheet.PrintPreview 'use this for testing
Next
Next pf
End Sub

'============================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top