Removing page break display on all worksheets

Yamezz

Active Member
Joined
Nov 22, 2006
Messages
367
Office Version
  1. 2019
For some dumb reason, Excel adds dashed page breaks to all the worksheets in my document when I have two monitors in use. I wrote some code to remove these but my code only operates on the active worksheet. How can I get it to remove the page breaks on all of the worksheets?
VBA Code:
Sub RemovePageBreaks()

' Keyboard Shortcut: Ctrl+Shift+P

Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
    ActiveSheet.DisplayPageBreaks = False
Next ws

End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
You need to use
VBA Code:
ws.DisplayPageBreaks = False
 
Upvote 0
ws.DisplayPageBreaks = False
Fluff, unfortunately that line neither operates on all worksheets in the document, nor does it remove the page break preview on the current worksheet.
 
Upvote 0
Is the code in the same workbook as the sheets you are trying to work on?
 
Upvote 0
Thanks Fluff. A lightbulb just went off... The code is in the Personal workbook, so of course ThisWorkbook doesn't refer to the ActiveWorkbook.
 
Upvote 0
Glad it's sorted & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,225,381
Messages
6,184,632
Members
453,248
Latest member
gmazee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top