View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Debra Dalgleish Debra Dalgleish is offline
external usenet poster
 
Posts: 2,979
Default Macro for pivot table and printing.....

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

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

JC wrote:
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.



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html