Consulting | Excel Examples

Inserting Automatic Page Breaks

You can use the subtotal feature to add a page break after each change in a sort key. For example, your can subtotal on vendor as shown in the figure below and Excel will add a page break for each vendor value. Use menu option Data, Subtotals and choose the Page Break Between Groups option.

 

 

You can also use this feature in VBA code:

Sub InsertSubTotal()

Range("A1").Select
Selection.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(2), _
Replace:=True, PageBreaks:=True, SummaryBelowData:=True

End Sub

 

Last modified: May 21, 1996