How to comment and uncomment blocks of code in the Office VBA Editor

RemarkLima picture RemarkLima · Oct 17, 2012 · Viewed 650.3k times · Source

In the VBA editor of Office (ALT + F11), how do you comment or uncomment a block of code?

Answer

RemarkLima picture RemarkLima · Oct 17, 2012

In the VBA editor, go to View, Toolbars, Customise... or right click on the tool bar and select Customise...

Under the Commands tab, select the Edit menu on the left.

Then approximately two thirds of the way down there's two icons, Comment Block and Uncomment Block.

Drag and drop these onto your toolbar and then you have easy access to highlight a block of code, and comment it out and uncomment with the click of a button!


See GauravSingh's answer if you want to assign keyboard shortcuts.