Have you ever wondered how these lines got there on a worksheet? They show where pages will break, in other words they show how the worksheet will be printed.

delete page break printer lines

If you click Page Break Preview button on tab "View" and then click "Normal" button, the lines appear. So how do you get rid of them?

You can´t easily disable them clicking a button on the ribbon, you must go to Excel Options.

  1. Go to tab "File" on the ribbon
  2. Click "Options"
  3. Click "Advanced"
  4. Scroll down to "Display options for this worksheet"
    hide page break printer lines
  5. Disable "Show page breaks"
  6. Click OK

Recommended article

Highlight a selected cell´s row and column

Today I would like to share to you these small event handler procedures that makes it easier for you to […]

Comments(9) Filed in category: Excel, VBA


The VBA solution

What happens if we record a macro while disabling "Page Breaks" in excel options?

This is what the macro recorder returns:

ActiveSheet.DisplayPageBreaks = False

Using that code you can now show or hide "Page Breaks" on the active sheet with a macro. Meaning, if "Page Breaks" are visible this macro hides them. If "Page Breaks" are hidden, the macro makes them visible.

Sub Macro1()
ActiveSheet.DisplayPageBreaks = Not ActiveSheet.DisplayPageBreaks
End Sub

The following macro shows or hides "Page Breaks" on every sheet in the current workbook.

Sub Macro2()
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
    sh.DisplayPageBreaks = Not sh.DisplayPageBreaks
Next sh
End Sub

This macro toggles "Page Breaks" on every sheet in every open workbook.

Sub Macro3()
Dim wb As Workbook
Dim sh As Worksheet
For Each wb In Workbooks
    For Each sh In wb.Worksheets
        sh.DisplayPageBreaks = Not sh.DisplayPageBreaks
    Next sh
Next wb
End Sub

Save this macro to your Excel ribbon

Add your personal excel macros to the ribbon

If you find yourself using the same macros over and over again, you can create a personal *.xlsb file that […]

Comments(2) Filed in category: Excel, User defined functions (udf), VBA


Download excel *.xlsm file

Toggle Page Break printer lines.xlsm