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.
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.
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.
3. Click OK. Now the data has been grouped and added 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.
4. Click OK, now the page breaks have been inserted.
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 200 handy functions, makes your jobs 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.
2. In the Insert Page Break Every Row dialog, type the interval as you need.
3. Click OK > OK to close dialogs, the page breaks have been inserted in every 2 rows.
Tabbed browsing & editing multiple Excel workbooks/Word documents as Firefox, Chrome, Internet Explore 10!
You may be familiar to view multiple webpages in Firefox/Chrome/IE, and switch between them by clicking corresponding tabs easily. Here, Office Tab supports similar processing, which allow you to browse multiple Excel workbooks or Word documents in one Excel window or Word window, and easily switch between them by clicking their tabs. Click for free 45-day trial of Office Tab!