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.
How to Insert Multiple Page Breaks in Excel: 2 Handy Approaches
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.
Download Practice Workbook
You may download the following Excel workbook for better understanding and practice it by yourself.
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. If you have any questions, comments, or recommendations, kindly leave them in the comment section below.