Sub SetupToPrint()
Call SetPrintAreaToPivotTable
Call SetPageBreakToXNumberOfRows
End Sub
Private Sub SetPrintAreaToPivotTable()
With ActiveSheet
lPTcells = .PivotTables("PivotTable1").DataBodyRange.Cells.Count
Set rngTopLeft = .PivotTables("PivotTable1").RowRange.Cells(1)
Set rngBotRight = .PivotTables("PivotTable1").DataBodyRange.Cells(lPTcells)
strPTAddress = rngTopLeft.Address & ":" & rngBotRight.Address 'strPT address don't exist!
.PageSetup.PrintArea = strAddress
End With
End Sub
Private Sub SetPageBreakToXNumberOfRows()
Dim Lastrow As Long
Dim Row_Index As Long
Dim RW As Long
'How many rows do you want between each page break
RW = 48
With ActiveSheet
'Remove all PageBreaks
.ResetAllPageBreaks
'Search for the last row with data in Column D
Lastrow = .Cells(Rows.Count, "D").End(xlUp).Row
For Row_Index = RW + 2 To Lastrow Step RW
.HPageBreaks.Add Before:=.Cells(Row_Index, 1)
Next
End With
End Sub
|