Hi People,
I have a macro I use (below) for auto printing Pivot Tables, which works by selecting an instance of the page field, printing, and then moving onto the next instance in the page field - which works great, except for a problem I have encountered recently which I cant work out how to overcome..
My Pivot table has evolved and now has 3 page fields. The macro I use assumes only one page field is present on the Pivot table and uses that to print from. I can workaround this by elevating whichever page field I want to print from to the first page field in the table layout. But how can I change the coding of the macro below to actually target a specific page field, I presume we could name the page fields and then tell the macro to target this instead of the first page field.
The name of the page field I am trying to print from is 'Stores'
Much appreciated, as always
I have a macro I use (below) for auto printing Pivot Tables, which works by selecting an instance of the page field, printing, and then moving onto the next instance in the page field - which works great, except for a problem I have encountered recently which I cant work out how to overcome..
My Pivot table has evolved and now has 3 page fields. The macro I use assumes only one page field is present on the Pivot table and uses that to print from. I can workaround this by elevating whichever page field I want to print from to the first page field in the table layout. But how can I change the coding of the macro below to actually target a specific page field, I presume we could name the page fields and then tell the macro to target this instead of the first page field.
The name of the page field I am trying to print from is 'Stores'
Code:
Sub PrintAll()
' Find name of page field
PageField1 = ActiveSheet.PivotTables("PivotTable1").PageFields(1)
' 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
End Sub
Much appreciated, as always