How to Comment/Uncomment Multiple Lines of VBA Code in Excel at Once?

Writing VBA code in Excel has many challenges. Sometimes we test and experiment with large blocks of code. In such cases it would be useful to have an option to comment or uncomment multiple lines at once. Otherwise, if we do it line by line, we can waste a lot of time.

This tip can actually save you a lot of time and energy. All you have to do is to select all lines of code you want to comment or uncomment.

To make this option visible go to View – Toolbars – and tick the Edit option.

edit toolbar

A new set of options will appear in the toolbar.

comment vba code
Among them you will find the Comment/Uncomment buttons, as you can see in the image.

This option can save you from hassle and wasting a lot of time when writing and experimenting with code, and many developers have overlooked it. It is always much easier to work with blocks of code, than having to comment or uncomment a single line by line.