Good Morning.
I was hoping you could help me speed up this macro for looping through a Pivot Table Field and printing each out come.
I originally did it this way as I was unsure how to unselect all the current items and just select the filter item. Hence the nested Loop.
/Comfy
I was hoping you could help me speed up this macro for looping through a Pivot Table Field and printing each out come.
Code:
Sub PrintAll()
Dim PT As PivotTable, pi1 As PivotItem, pi2 As PivotItem
Dim pvtFilter As String
Application.ScreenUpdating = False
pvtFilter = Range("A3").Value
Set PT = ActiveSheet.PivotTables(1)
With PT
.ManualUpdate = True
For Each pi1 In .PivotFields(pvtFilter).PivotItems
pi1.Visible = True
For Each pi2 In .PivotFields(pvtFilter).PivotItems
If Not pi2.Name = pi1.Name Then pi2.Visible = False
Next pi2
ActiveCell.CurrentRegion.PrintOut Copies:=1
Next pi1
.ManualUpdate = False
End With
Application.ScreenUpdating = True
MsgBox "All Done :)"
End Sub
I originally did it this way as I was unsure how to unselect all the current items and just select the filter item. Hence the nested Loop.
/Comfy