I have a looping macro to print a page for each filtered item in a pivot table. What I'd like to do is add the sleep command to have it wait for about 2 to 3 seconds before it goes to the next item.
I'm wanting to slow it down as I had issues with it before of just printing the first value and not going on to the 2nd one, then getting caught in a never ending loop. So I want to slow it down in case I need to stop the macro for any reason.
Any suggestions?
Code:
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
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
Next
Next pf
End Sub
I'm wanting to slow it down as I had issues with it before of just printing the first value and not going on to the 2nd one, then getting caught in a never ending loop. So I want to slow it down in case I need to stop the macro for any reason.
Any suggestions?