Skip to main content
 

How to conditional inserting page breaks in Excel?

Author: Sun Last Modified: 2022-03-04

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

Distinguish Differences to insert page break when data change

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()
'UpdatebyExtendOffice20181101
    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.


Distinguish Differences to insert page break when data change

The Distinguish Differences feature of Kutools for Excel supports to insert page break, blank row, bottom border or background color when data change in Excel.

Kutools for Excel, equipped with AI 🤖, offers over 300 handy features to simplify your tasks.

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

Click Kutools > Format > Distinguish Differences.
doc conditional insert page break 5

2. In the Distinguish differences by key column dialog, please finish below settings:

1) click selection icon doc conditional insert page break 5 in the Range section, select the data range (excluding column headers)

2) click selection icon doc conditional insert page break 5 in the Key column section, select the column that you want to insert page break based on corresponding data change (excluding column headers)

3) check Page Break option in Options section.
doc conditional insert page break 5

3. Click Ok.

Now page breaks is inserted when data change in the selected range.
doc conditional insert page break 5


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.

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



Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


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!