Removing page break display on all worksheets

Yamezz

Active Member
Joined
Nov 22, 2006
Messages
372
Office Version
  1. 365
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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You need to use
VBA Code:
ws.DisplayPageBreaks = False
 
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,226,466
Messages
6,191,196
Members
453,646
Latest member
SteenP

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