How to insert page break every x rows in Excel?
It may be easy and simple for you to insert a page break into a worksheet. Sometimes, it's required to insert page breaks in every X rows for printing tidily, how could you do? Here I introduce a couple of methods to solve this problem in Excel.
- Insert page break every X rows with VBA in Excel
- Batch insert page breaks after every x rows
- Batch insert page breaks after every x rows with adding row heading above every x rows
Maybe you are not familiar with VBA running before, but with the follow steps you may know how to run the VBA to insert a page break every X rows. Here I will insert a page break in every 3 rows.
1. Press Alt + F11 to display the Microsoft Visual Basic for Applications window.
2. In the window, click Insert > Module to show a new module window, then copy the following VBA code into the module window.
VBA: Insert page break in every X rows in a worksheet.
Sub InsertPageBreaks() 'Updateby20140618 Dim xLastrow As Long Dim xWs As Worksheet Set xWs = Application.ActiveSheet xRow = Application.InputBox("Row", xTitleId, "", Type:=1) xWs.ResetAllPageBreaks xLastrow = xWs.Range("A1").SpecialCells(xlCellTypeLastCell).Row For i = xRow + 1 To xLastrow Step xRow xWs.HPageBreaks.Add Before:=xWs.Cells(i, 1) Next End Sub
3. Click Run button and a dialog pops out for you to specify every X rows you want to insert a page break in. Here I insert page break in every 3 rows. See screenshot:
4. Click OK, and then it will insert a page break in every X rows.
If you have Kutools for Excel installed, its Split to Columns utility can help you batch insert multiple page breaks after every x rows with keeping title in each page easily in Excel.
1. Click Split to Columns on the Kutools Plus tab.
2. In the opening Split to Columns dialog box, you need to:
(1) Click the Browse button in the Titles range box, and select the title row in the specified range that you will batch insert page breaks.
(2) Click the Browse button in the Date range box, and select the range that you will batch insert page breaks.
(3) In the Rows per printed page box, enter a number. (Tip: For example, if you need to insert page breaks after every 3 rows, please enter 3 into the box; if you need to inert page breaks after every row, please enter 1.)
(4) Enter 1 into the Number of segments box.
3. Click the Ok button.
Now you will see the range is copied into a new worksheet, and page breaks are added after every x rows with keeping range title. You can also switch to the Page Break Preview view by clicking View > Page Break Preview to see these page breaks. See below screen shot.
Kutools for Excel develops another Insert Page Break Every Row utility specializing in inserting page breaks after every x rows at ease.
1. Select the range that you will insert page breaks after every x rows, and click Printing > Insert Page Break Every Row on the Kutools Plus tab.
2. In the opening Insert Page Break Every Row dialog box, specify the interval of rows that you will insert page breaks at, and click the Ok button.
Then you will see page breaks are inserted at the specified interval of rows at once.