In VBA is there a short way to comment out a block of code the same way java uses /*...*/?
- 4Yes and it's called "Comment Block" AND, it may not be present on your toolbar. If not, right click a toolbar in the VBE and choose "Customize". On the Commands tab, choose "Edit" and scroll down the Commands list until you find it. Drag to a toolbar. Do the same for the "Uncomment Block" icon from hereMark C.– Mark C.2014-06-02 19:08:38 +00:00Commented Jun 2, 2014 at 19:08
- stackoverflow.com/a/12933280/3198973RubberDuck– RubberDuck2014-06-02 19:11:19 +00:00Commented Jun 2, 2014 at 19:11
3 Answers
Although there isn't a syntax, you can still get close by using the built-in block comment buttons:
If you're not viewing the Edit toolbar already, right-click on the toolbar and enable the Edit toolbar:

Then, select a block of code and hit the "Comment Block" button; or if it's already commented out, use the "Uncomment Block" button:

Fast and easy!
1 Comment
prefix the comment with a single-quote. there is no need for an "end" tag.
'this is a comment Extend to multiple lines using the line-continuation character, _:
'this is a multi-line _ comment This is an option in the toolbar to select a line(s) of code and comment/uncomment:

12 Comments
There is no syntax for block quote in VBA. The work around is to use the button to quickly block or unblock multiple lines of code.