Remove Page Breaks With A Quick Excel VBA Macro – Macro Mondays


Hello Excellers, time for a quick bit of Excel Macro VBA coding on a Monday. What could be better?. It is time to get Excel to all the hard work for us if we can right?. Today I will help you remove those annoying page breaks in Excel. You know the ones that insist on staying around even when you have navigated from the Page Break Preview back to Normal View.

Excel VBA Macro page breaks

Now as annoying these are, you can get rid of them with the following process-

  • File | Options | Advanced
  • Display Options For This Worksheet | Untick Show Page Breaks

Well if you do not want to go through all of that you can write a few lines of code you can store in your Personal Macro Workbook. Then you can call on anytime you want to when Excel is open to solving this annoying problem.

What Does The Macro Do?

This small macro will get rid those page breaks in Excel that are so annoying.

How Does The Macro Work?

Step 1. Hit ALT+F11 to open the Excel VBA Developer Tab

Step 2. We want to store this piece of code where it is available all of the time in an Excel workbook. Lets, therefore, insert a New Module into our Personal Macro Workbook.

VBA to remove Excel page breaks

Step 3. Now we write our code. its a one-liner but handy. All we do is set the Display Page Breaks property to False in the active worksheet.

Step 4. Test your Code.

Add The Macro To The Quick Access Toolbar

That is so simple let’s add in a few more steps to make this macro even more useful. Let’s add it as a button to our Quick Access Toolbar and make it even more handy to use. Once you have created your Macro, there are just a few short steps to get attached to a button on the Quick Access Toolbar.

  • File – Options- Quick Access Toolbar
  • In the Choose Commands From – select Macro
  • Select the Macro you want to attach to
  • Click Add to move the Macro to a list of buttons on the Quick Access Toolbar
  • If you want to replace the Icon then click Modify
  • Under Symbol, select the one you want
  • Under Display Name – change the name if you want to use a more friendly name

Excel macro page breaks

Finally, all you need to do is test it out again for yourself. It now sits on your Quick Access Toolbar.

Do You Want To Copy The Code?

Sub disablePageBreaks()

‘Macro by How To Excel At Excel

ActiveSheet.DisplayPageBreaks = False

End Sub


If you want more Excel and VBA tips then sign up for my monthly Newsletter where I share 3 Excel Tips on the first Wednesday of the month and receive my free Ebook, 30 Excel Tips.

If you want to see all of the blog posts in the Macro Mondays Series or the example worksheets you can do so by clicking on the links below.

How To Excel At Excel – Macro Mondays Blog Posts.

Learn Excel With Our Excel Online Courses


Do You Need Help With An Excel Problem?.

Finally, I am pleased to announce I have teamed up with Excel Rescue, where you can get help with Excel FAST. Why not check it out?.

ExcelRescue.net

Barbara

Barbara is an experienced data analyst with over 20 years of experience. Author of the How To Excel At Excel Top 50 Excel tips Ebook, YouTuber and Excel Blogger.

Recent Posts