We have three different data tables, each containing the names, IDs, and joining dates of employees of three different companies. We’ll solve the most common problems with page breaks.
Solution 1 – Using Page Setup Group
Steps:
- Insert page breaks in the worksheet.
- Select row 9.
- Go to the Page Layout tab of the ribbon.
- In the Page Setup group, choose the Insert Page Break command from the Breaks drop-down menu.
- Follow the same process to insert the page break in row 17.
- There are no page breaks in those rows.
- Go to the Page Layout tab of the ribbon again.
- Click on the little arrow on the lower right side of the Page Setup group.
- You will see a dialog box named “Page Setup”.
- In the Page tab of the dialog box, choose the option Adjust to if it was not marked previously.
- Press OK.
- You will see the page breaks in the worksheet.
Read More: How to Remove Automatic Page Break in Excel
Solution 2 – Applying VBA Code to Fix Page Break Issue
Steps:
- Insert page breaks in rows 10 and 17.
- You will not notice any page breaks on the worksheet after applying the Insert Page Break command.
- Go to the Developer tab of the ribbon and choose the Visual Basic command from the Code group.
- You will see a new tab.
- Choose the Module command from the Insert tab.
- Insert the following code into the module.
Sub Page_Break_Not_Working()
'Communication with the printer is turned off
Application.PrintCommunication = False
'Set the print area to cell B2:D23 on sheet VBA
ActiveSheet.PageSetup.PrintArea = "$B$2:$D$23"
'Switch the display in VBA sheet to page break preview
ActiveWindow.View = xlPageBreakPreview
ActiveWindow.View = xlNormalView
End Sub
- We will name the function in the VBA as Page_Break_Not_Working.
- We will declare the communication of the worksheet with printer is turned on or off.
- We will set the worksheet area or cell range within which the page break will be applied by using the command line .ActiveSheet.PageSetup.PrintArea = “$B$2:$D$23”
- We will write the xlPageBreakPreview command to show the page break in the worksheet.
- Save the code and press the play button or F5 for the solution.
- You will see page breaks in the worksheet after running the code.
Read More: How to Insert Page Break Based on Cell Value with Excel VBA
Download the Practice Workbook
Related Articles
- How to Remove the Page Break Lines in Excel
- How to Remove Print Lines in Excel
- How to Remove Blue Lines in Excel
<< Go Back to Page Setup | Print in Excel | Learn Excel
Get FREE Advanced Excel Exercises with Solutions!
Extra, thanks for helping me –
Hello Chris,
You are most welcome.
Regards
ExcelDemy