Add a ' in front of all highlighted code in VBA

  • Thread starter Thread starter RyanH
  • Start date Start date
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.
 
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.
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top