Skip to main content

Kutools for Office — One Suite. Five Tools. Get More Done.

How to insert page breaks when value changes in Excel?

Author Xiaoyang Last modified
A screenshot of data where page breaks will be inserted when values change

Suppose you have a list of data in a worksheet, and you need to insert page breaks each time the value in column A changes, as shown in the screenshot on the left. Manually inserting page breaks one by one can be time-consuming, especially for large datasets. Fortunately, there are several practical methods available to insert page breaks based on value changes efficiently. This article will detail multiple solutions, covering scenarios both with and without VBA or add-ins, to help you choose the approach best suited for your task.


Insert page breaks when value changes with VBA code

If you need to insert page breaks automatically each time a value changes in a specific column, using VBA can accomplish this efficiently. This method is suitable for users who are comfortable working with Excel macros and want an automated approach.

1. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and paste the following code in the Module window.

VBA code: Insert page breaks when the value changes:

Sub insertpagebreaks()
'updateby Extendoffice
    Dim I As Long, J As Long
    J = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
    For I = J To 2 Step -1
        If Range("A" & I).Value <> Range("A" & I - 1).Value Then
            ActiveSheet.HPageBreaks.Add Before:=Range("A" & I)
        End If
    Next I
End Sub

3. Press the F5 key to run this code. Excel will automatically add page breaks at each point where the data in column A changes. See screenshot below:

A screenshot of the inserted page breaks in Excel when values in column A change

Note: In the code above, A refers to the column to check for value changes. Change "A" to the appropriate column letter as needed. Make sure your worksheet is saved or backed up before running VBA, as bulk changes are made automatically.

This VBA approach is very flexible and suitable for large datasets or repeated tasks. However, if you are not familiar with VBA or your environment restricts macros, consider the following alternative methods.


Insert page breaks when value changes with a powerful feature

With Kutools for Excel, you can quickly add page breaks every time values change in a selected column, and also apply other formatting actions, such as inserting blank rows, adding border lines, or filling background color on value change. This feature is especially convenient if you frequently require such data formatting, and it does not require writing or understanding code. Click to download Kutools for Excel.

A screenshot of how Kutools for Excel inserts page breaks when value changes

Kutools for Excel offers over 300 advanced features to streamline complex tasks, boosting creativity and efficiency. Itegarate with AI capabilities, Kutools automates tasks with precision, making data management effortless. Detailed information of Kutools for Excel...         Free trial...

1. On your worksheet, go to the Kutools tab, then click Format > Distinguish differences. Refer to the screenshot:

A screenshot of selecting the Distinguish Differences option in Kutools tab on the ribbon

2. In the Distinguish differences by key column dialog box:

  • Select the data range you want to work with and specify the key column (usually the column where you want to detect value changes).
  • Choose Page Break under Options.

A screenshot of the Distinguish Differences dialog box

3. Click the OK button. Kutools will automatically add page breaks at each point where the specified column's value changes. The screenshot below shows the result:

A screenshot of the inserted page breaks in Excel when values in column A change

Kutools for Excel - Supercharge Excel with over 300 essential tools. Enjoy permanently free AI features! Get It Now

This method is particularly user-friendly and helpful for those who do not want to code or manage macros. It is also useful for handling a wide range of similar formatting needs beyond page breaks.


Identify where breaks should go with a formula helper column

You can use an Excel formula to help flag when the value changes in a column, which then guides where manual page breaks should be inserted. While standard formulas cannot insert page breaks directly, they make it easy to spot where breaks are needed. This method is especially useful if you prefer to avoid macros or add-ins and have a small-to-moderate dataset.

Applicable scenarios: Use this approach if you want a visual guide to insert page breaks without any automation, or when working in environments where macros or add-ins are not allowed.

For example, suppose your data is in column A starting from row 2. To identify where values change:

1. Enter the following formula in cell B2:

=A2<>A1

This formula compares each cell in column A with the one above it. It will display TRUE when the value in A2 is different from A1, indicating a change.

2. Copy the formula down to apply it to other rows.

Now, each TRUE in column B shows where the value in column A changes. You can manually add a page break immediately before or after each row where a change is indicated.

Alternatively, you can use an IF formula to make the indication even clearer. Enter the following in B2:

=IF(A2<>A1, "Insert Break", "")

This will display "Insert Break" where the value changes for easier visual scanning.

  • Tip: After marking, go through your sheet and insert page breaks at each marked position as needed (Page Layout > Breaks > Insert Page Break).

Pros: No need for code or add-ins, and easy to implement for small or moderate datasets.
Cons: Requires manual insertion of page breaks and may be tedious on very large lists.


More relative articles:

  • Highlight Rows When Cell Value Changes In Excel
  • If there is a list of repeated values in your worksheet, and you need to highlight the rows based on column A, whose cell value changes as the following screenshot. In fact, you can quickly and easily finish this job by using the Conditional Formatting feature.
  • Increment Numbers When Value Changes In Another Column
  • Supposing you have a list of values in column A, and now you want to increment the number by 1 in column B when the value in column A changes, which means the numbers in column B increment until the value in column A changes, then the number increment starts from 1 again, as left screenshot. In Excel, you can solve this problem with the following method.
  • Sum Cells When Value Changes In Another Column
  • When you work on an Excel worksheet, sometimes you may need to sum cells based on a group of data in another column. For example, here, I want to sum the orders in column B when the data changes in column A to get the following result. How could you solve this problem in Excel?
  • Insert Blank Rows When Value Changes In Excel
  • Supposing you have a range of data, and now you want to insert blank rows between the data when the value changes, so that you can separate the sequential same values in one column as following screenshots. In this article, I will talk about some tricks for you to solve this problem.
  • Run Macro When Cell Value Changes In Excel
  • Normally, in Excel, we can press the F5 key or the Run button to execute the VBA code. But have you ever tried to run the specific macro code when a cell value changes? In this article, I will introduce some quick tricks to deal with this job in Excel.

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
Use Kutools in your preferred language – supports English, Spanish, German, French, Chinese, and 40+ others!

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!

All Kutools add-ins. One installer

Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.

Excel Word Outlook Tabs PowerPoint
  • All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
  • One installer, one license — set up in minutes (MSI-ready)
  • Works better together — streamlined productivity across Office apps
  • 30-day full-featured trial — no registration, no credit card
  • Best value — save vs buying individual add-in