OzGrid

Printing PivotTables & PivotCharts

< Back to Search results

 Category: [Excel]  Demo Available 

Printing PivotTables & PivotCharts

 

 Print Each Page Field (Report Filter) Of Pivot Tables & Pivot Charts

 

Sub PrintAllPivotPageFields()

Dim pt As PivotTable, pi As PivotItem, pf As PivotField

Dim lLoop As Long

 

''Wrtten by www.ozgrid.com

''Prints out each PivotTable PageField

 

Set pt = Sheet1.PivotTables(1) 'Change to suit

''http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm

Set pf = pt.PageFields(1) 'Change to suit

 

    For Each pi In pf.PivotItems

        pi.Value = pi.Value

            If lLoop = 0 Then

                With Sheet1.PageSetup

                    .CenterFooter = pi.Value

                    .LeftHeader = pt.Name

                    .LeftFooter = Now

                    .PrintArea = pt.TableRange2.Address

                End With

            End If

        Sheet1.PrintOut

        lLoop =lLoop +1

    Next pii

End Sub
Sub PrintAllPivotChartPageFields()

Dim pt As PivotTable, pi As PivotItem, pf As PivotField

Dim lLoop As Long

 

''Wrtten by www.ozgrid.com

''Prints out each PivotChart PageField

 

Set pt = Sheet1.PivotTables(1) 'Change to suit

''http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm

Set pf = pt.PageFields(1) 'Change to suit

 

    For Each pi In pf.PivotItems

        pi.Value = pi.Value

            If lLoop = 0 Then

                With Chart4.PageSetup ''CodeName of PivotChart Chart Sheet

                    ''http://www.ozgrid.com/VBA/excel-vba-sheet-names.htm

                    .CenterFooter = pi.Value

                    .LeftHeader = pt.Name

                    .LeftFooter = Now

                End With

            End If

        Chart4.PrintOut

        lLoop = lLoop + 1

    Next pi

End Sub

 

 

See also:

Excel VBA: Hide/Show Pivot Table Field Items
Refresh Pivot Table via VBA

 

See also Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions.

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.

Microsoft®, Microsoft Excel® and Google® are registered trademarks of Microsoft Corporation. OzGrid is in no way associated with Microsoft or Google. 

©2019 ozgrid. All right reserved


Gallery



stars (0 Reviews)