To divide a table into two sections for printing or to divide a table into two, we may need to insert a page break. If not, Excel will print the worksheet using its built-in page breaks, paper size, etc. Depending on our preferences, we can manually insert page breaks to print a worksheet. In this article, we will show you how to Insert Multiple Page Breaks in Excel.
Download Practice Workbook
You may download the following Excel workbook for better understanding and practice it by yourself.
2 Handy Approaches to Insert Multiple Page Breaks in Excel
When printing a worksheet, page breaks are used to divide it into distinct pages. Excel will utilize default page breaks that are set to the size of a printed page if you don’t set them, and this nearly never looks good. In the following two methods, you will learn a very convenient method to insert multiple page breaks in Excel by applying VBA Code and utilizing the Page Layout tab manually as well. Let’s suppose we have a sample data set.
1. Utilizing the Page Layout tab to Insert Multiple Page Breaks in Excel
In this first method, you will learn how to insert multiple page breaks in Excel by utilizing the Page Layout tab.
- Just to the right of where you want the page break to occur, choose one entire row. Here, we will select multiple rows one by one after using a one-page break every time.
- Firstly, select the Page Layout tab.
- Secondly, choose the Breaks tool.
- Thirdly, click on the Insert Page Break command.
- The consequences of 10 repeated page breaks will finally be inserted with respect to the X-axis, as you can see.
- As you can see, the effects of 5-page breaks will be added with respect to the Y-axis also.
2. Applying VBA Code to Insert Multiple Page Breaks in Excel
In this last section, we will generate a VBA code utilizing the Developer tab to insert multiple page breaks in Excel.
- At first, we will use the Developer tab.
- Then, we will select the Visual Basic command.
- Here, the Visual Basic window will open.
- After that, from the Insert option, we will choose the new Module to write a VBA Code.
- Now, paste the following VBA code into the Module.
- To run the program, click the “Run” button or press F5.
Sub Insert_Multiple_PageBreaks() 'Declaring variable for lastrow Dim Lastrow As Long 'Declaring Mysheet as worksheet Dim Mysheet As Worksheet 'Setting Mysheet for Activesheet Set Mysheet = Application.ActiveSheet 'Type row number for how much row gap you need to insert page breaks Row = Application.InputBox("Enter Row Number", TitleId, "", Type:=1) 'Reset all page breaks Mysheet.ResetAllPageBreaks 'Page breaks starts from B1 cell till last row with respect to X axis Lastrow = Mysheet.Range("B1").SpecialCells(xlCellTypeLastCell).Row For i = Row + 1 To Lastrow Step Row Mysheet.HPageBreaks.Add Before:=Mysheet.Cells(i, 1) Next End Sub
VBA Code Breakdown
- Firstly, we call our Sub Procedure Insert_Multiple_PageBreaks.
- Then, we refer to our current Worksheet as ActiveSheet.
- Besides, we enter our row number using Row = Application.InputBox(“Enter Row Number”, TitleId, “”, Type:=1).
- Finally, Page breaks will start from the B1 cell till the last row with respect to X-axis using Lastrow = Mysheet.Range(“B1”).SpecialCells(xlCellTypeLastCell).Row and For i = Row + 1 To Lastrow Step Row
- Now, enter the row number here. We will choose 1 for the entire row.
- Then, click OK.
- Finally, you will observe that the results of 15-page breaks for the entire will be inserted with respect to the X-axis.
In this article, I’ve covered 2 handy methods to Insert Multiple Page Breaks in Excel. I sincerely hope you enjoyed and learned a lot from this article. Additionally, if you want to read more articles on Excel, you may visit our website, Exceldemy. If you have any questions, comments, or recommendations, kindly leave them in the comment section below.
- How to Move Page Breaks in Excel (With Easy Steps)
- Use Page Break in Excel (7 Suitable Examples)
- How to Remove Automatic Page Break in Excel (3 Easy Ways)
- Insert Page Break Between Rows 39 and 40 in Excel
- [Solved]: Page Break in Excel Not Working Error
- How to Remove the Page Break Lines in Excel (3 Ways)