Note: The other languages of the website are Google-translated. Back to English
Log in  \/ 
Register  \/ 


How to conditional inserting page breaks in Excel?

Supposing you need to insert page breaks while the values are changed in column A as below screenshot shown, how could you handle it in Excel? Generally, you can insert the page breaks one by one manually, but here, I introduce some tricks on solving this quickly.
doc conditional insert page break 1

Using Subtotal function to insert page breaks

Using VBA code to insert page breaks

Insert Page Break Every Row to insert page break in nth rowsgood idea3

Using Subtotal function to insert page breaks

In Excel, the Subtotal function can add page breaks based on group.

1. Select the data you want to add page breaks, click Data > Subtotal.
doc conditional insert page break 2

2. In the Subtotal dialog, select the column you want to insert page break based on its value in At each change in drop down list, then choose the function you want to use from Use function list, then check Page break between groups checkbox and other options as you need.
doc conditional insert page break 3

3. Click OK. Now the data has been grouped and added page breaks.
doc conditional insert page break 4

Using VBA code to insert page breaks

If you do not want to add groups to the data, you can try VBA code to handle this job.

1. Press Alt + F11 keys to display Microsoft Visual Basic for Applications window.

2. Click Insert > Module, copy and paste below code to the new Module window.

VBA: Insert page breaks when data changes

Sub PageBreak()
    Dim xSRg As Range
    Dim xRg As Range
    On Error Resume Next
    Set xSRg = Application.InputBox("Select key column:", "Kutools for Excel", xTxt, , , , , 8)
    If xSRg Is Nothing Then Exit Sub
Application.ScreenUpdating = False
    For Each xRg In xSRg
        ActiveSheet.Rows(xRg.Row).PageBreak = xlPageBreakNone
        If xRg.Value <> xRg.Offset(-1, 0).Value Then
            ActiveSheet.Rows(xRg.Row).PageBreak = xlPageBreakManual
        End If
    Next xRg
Application.ScreenUpdating = True
End Sub


3. Press F5 key, a dialog pops out to remind you select the key column which insert page break based on.
doc conditional insert page break 5

4. Click OK, now the page breaks have been inserted.

Insert Page Break Every Row to insert page break in nth rows

If you want to insert page breaks in a fixed interval, you can use Kutools for Excel’s Insert Page Every Row utility to quickly handle the problem.

Kutools for Excel, with more than 300 handy functions, makes your jobs more easier. 

After installing Kutools for Excel, please do as below:(Free Download Kutools for Excel Now!)

1. Select the data and click Kutools Plus > Printing > Insert Page Break Every Row.
doc conditional insert page break 6

2. In the Insert Page Break Every Row dialog, type the interval as you need.
doc conditional insert page break 7

3. Click OK > OK to close dialogs, the page breaks have been inserted in every 2 rows.
doc conditional insert page break 8

The Best Office Productivity Tools

Kutools for Excel Solves Most of Your Problems, and Increases Your Productivity by 80%

  • Reuse: Quickly insert complex formulas, charts and anything that you have used before; Encrypt Cells with password; Create Mailing List and send emails...
  • Super Formula Bar (easily edit multiple lines of text and formula); Reading Layout (easily read and edit large numbers of cells); Paste to Filtered Range...
  • Merge Cells/Rows/Columns without losing Data; Split Cells Content; Combine Duplicate Rows/Columns... Prevent Duplicate Cells; Compare Ranges...
  • Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
  • Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
  • Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
  • Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
  • Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
  • More than 300 powerful features. Supports Office/Excel 2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features 30-day free trial. 60-day money back guarantee.
kte tab 201905

Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
officetab bottom
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.