Quickly Comment/Uncomment code in VBA

Unfortunately, there’s no shortcut for commenting/uncommenting blocks of code in VBA – but there are a couple of handy buttons you can add to your toolbar to save you from going through and adding/removing apostrophes from every. single. line!

Just follow these steps to turn on the toolbar buttons:

  • In your Excel workbook, if you don’t already have the VBA Editor open, open it with ALT+F11
  • In the VBA Editor go to View>Toolbars>Customise
  • In the Commands tab Categories menu select ‘Edit’
  • In the Commands tab Commands menu scroll down until you find ‘Comment Block’ and ‘Uncomment Block’
  • commentuncomment
  • Drag and drop these onto your toolbar where you want them.

Now when you are writing code, all you need to do to comment/uncomment code is highlight the text and press one of these handy dandy buttons!


2 thoughts on “Quickly Comment/Uncomment code in VBA

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s