When clearing page breaks in Excel VBA you need to be careful. There is one command that will clear page breaks but it will also affect other print settings.
If you use
ActiveSheet.ResetAllPageBreaks
You may also reset many other print settings.
To remove just the page breaks it can be better to use
ActiveSheet.Cells.PageBreak = xlPageBreakNone
If the sheet is using the Page Break Preview View the above line of code will crash the macro. It is safer to use the following two lines of code.
ActiveWindow.View = xlNormalView ActiveSheet.Cells.PageBreak = xlPageBreakNone
This avoids crashing the macro.
Related Posts
Please note: I reserve the right to delete comments that are offensive or off-topic.