banner



How To Get Rid Of Dotted Lines In Excel

Author: Oscar Cronquist Article last updated on August 22, 2020

Picture shows print preview page break dotted lines

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

If you press with left mouse button on Page Break Preview button on tab "View" and then press with left mouse button on "Normal" button, the lines appear, however, they don't disappear automatically.

So how do you get rid of them? You can't easily disable them press with left mouse button oning a button on the ribbon, unfortunately, you must go to the Excel Options and disable it there. See detailed instructions below.

I made a macro, demonstrated later in this article, that you can use to quickly disable the print preview lines, put it in your personal toolbox and use it whenever necessary.

There is also a macro-enabled workbook for you to get further down in this post. It seems that if you close the workbook and then open it again the print preview lines disappear, however, this is in my opinion to much work to only remove the lines.

How to remove dotted lines (Excel Options)

  1. Press with mouse on tab "File" on the ribbon.
    Picture shows tab File on the ribbon
  2. Press with mouse on "Options"
  3. Press with mouse on tab "Advanced".
  4. Scroll down to "Display Options for this worksheet".
    Picture of Excel Options and tab Advanced
  5. Disable "Show Page Breaks".
  6. Press with left mouse button on "OK" button.

How to remove dotted lines (Immediate window)

If you are familiar with the Immediate window in the Visual Basic Editor you can probably more quickly delete the print preview lines than through Excel Options.

  1. Copy code below.
  2. Press Alt+F11 to open the VB Editor.
  3. Paste code to the Immediate window
  4. Press Enter
  5. Return to Excel
ActiveSheet.DisplayPageBreaks = False        

How to remove print preview dotted lines [Excel 2007]

  1. Press with left mouse button on the Office button located at the top left side of your screen.
    Picture of Office button
  2. Press with left mouse button on "Excel Options".
  3. Press with left mouse button on tab "Advanced" in the left window.
  4. Find "Display Options for this Worksheet".
  5. Disable the check box "Show Page Breaks"
  6. Press with left mouse button on "OK" button.

How to remove print preview dotted lines [Excel 2003]

  1. Go to the Tools menu.
  2. Press with left mouse button on Options.
  3. Press with left mouse button on the View tab.
  4. Disable checkbox Page Breaks found in Windows Options.
  5. Press with left mouse button on OK button.

Excel 2011 Macintosh

Picture of how to go to preferences in Excel 2011 for Mac

  1. Go to "Preferences" on the menu.
  2. Press with left mouse button on View in "Authoring".
  3. Disable checkbox "Show Page Breaks" located below "Windows Options"

Build a macro and automate these steps

If you often disable print preview lines manually why not build a macro that does it for you? It is not hard, simply copy the macro and paste it to your workbook module.

If you want to use it any workbook you open, put it in a personal macro workbook and link it to the Quick Access Toolbar or the ribbon.

Picture of Quick Access Toolbar above ribbon in excel

In fact, you can save useful macros in your personal macro workbook and become a lot more efficient in your work.

Macro to disable print preview lines

Picture of VB Editor displaying macro to remove print preview lines

What happens if we record a macro while disabling "Page Breaks" in Excel options? This is what the macro recorder returns:

Macro1() ActiveSheet.DisplayPageBreaks = False End Sub        

Use the above line in the examples below if you don't want to toggle print preview lines.

Macro toggles print preview lines on the active worksheet

Picture of VB Editor displaying macro to toggle print preview lines

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        

Macro toggles print preview lines on every sheet in the workbook

Picture of VB Editor displaying macro to toggle print preview lines on every worksheet

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        

Macro toggles print preview lines on every sheet in all open workbooks

Picture of VB Editor displaying macro to toggle print preview lines on every worksheet in all open workbooks

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        

Watch a video where I explain how to use the macros above

Where to put the code

  1. Copy the preferred macro above.
  2. Go to Visual Basic Editor (VBE). (Alt + F11)
    Picture of where to put the vba code in the VB Editor
  3. Press with left mouse button on "Insert" on the menu.
  4. Insert a new module.

Don't forget to save the workbook as a macro-enabled workbook  (*.xlsm file) or the macro is gone the next time you open the workbook.

Here is how to put this macro on the Excel ribbon:

Customize the ribbon and how to add your macros

Recommended articles

  • Print gridlines in a worksheet
  • Page Break Preview

How To Get Rid Of Dotted Lines In Excel

Source: https://www.get-digital-help.com/remove-print-preview-lines-page-breaks/

Posted by: hallrosed1985.blogspot.com

0 Response to "How To Get Rid Of Dotted Lines In Excel"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel