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’
- 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!