Add a ' in front of all highlighted code in VBA

R

RyanH

I remember reading this somewhere and can't find it. Is there a way to add a
' in front of all the code that is highlighted in VBA? For example, I want
ignore a portion of code for testing, I highlight the code and do something
to make them all comments. Plus I would like to beable to switch it back.
 
R

Rick Rothstein

I don't think there is a keyboard shortcut available; however, you can add
two buttons to the toolbar to make the task doable with a single mouse
click. Click View/Toolbars/Customize from the VB editor's menu bar, click
the Commands tab on the dialog box that appears, select Edit from the
Categories list and then scroll down until you find "Comment Block" and
"Uncomment Block" in the Commands list. Click, drag and drop each one of
them onto the menu bar. You can now Close the Customize dialog box. To use
the buttons, highlight several lines of code and click the "Comment Block"
icon and those line will turn into comments. Highlight any comment lines and
click the "Uncomment Block" icon and those lines will become normal
statements.
 
R

RyanH

Now I remember. Thanks!
--
Cheers,
Ryan


Rick Rothstein said:
I don't think there is a keyboard shortcut available; however, you can add
two buttons to the toolbar to make the task doable with a single mouse
click. Click View/Toolbars/Customize from the VB editor's menu bar, click
the Commands tab on the dialog box that appears, select Edit from the
Categories list and then scroll down until you find "Comment Block" and
"Uncomment Block" in the Commands list. Click, drag and drop each one of
them onto the menu bar. You can now Close the Customize dialog box. To use
the buttons, highlight several lines of code and click the "Comment Block"
icon and those line will turn into comments. Highlight any comment lines and
click the "Uncomment Block" icon and those lines will become normal
statements.
 
Top