Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 5 of 5

Thread: Comment Out VBA Code Blocks

  1. #1
    Join Date
    25th January 2003
    Location
    UK
    Posts
    2,745

    Comment Out VBA Code Blocks

    We all know that adding a ' (single quote) before the contents of a line, or part of a line, in the VBE will make it a comment (shows in green by default).

    It is often useful when testing your code to comment-out various bits of code so that they don't run. When I first started VBA coding I would scroll down adding one quote at a time to each line concerned. (And then deleting each quote after testing).

    There is a much easier way (isn't there always?) available from the Edit menu commands but the options aren't shown by default. There are 'Comment Block' and 'Uncomment Block' options that let you add or delete comment indicators to selected blocks of code.

    To make these easily accessable try this:
    1. In the VBE go to View/Toolbars/Customise.
    2. Select the Commands tab and then the Edit category.
    3. Scroll down the list of commands until you see Comment Block and Uncomment Block.
    4. Press and hold the left mouse button when over the command and drag it to your Standard toolbar (and then let go of the mouse button!).
    5. Repeat for the other option.

    Of course you could just make the Edit toolbar visible - it depends on how much screen area you have available. Either way, these commands are very useful.
    Cross-poster? Read this: Cross-posters
    Struggling to use tags (including Code tags)? : Forum tags

  2. #2
    Join Date
    8th December 2010
    Posts
    1

    Smile Re: Comment Out VBA Code Blocks

    Still valid nearly 8 years later! Thanks for the tip!!!

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    12th April 2011
    Posts
    1

    Re: Comment Out VBA Code Blocks

    wow, thanks for that!

    It's sad how a person can use a product for so long (feels like centuries) and be annoyed every time that I've put the comments in individually (cursing that I can't use something like /* */ to surround entire blocks and right in the middle of the options list there they were; Mr & Mrs comment and uncomment

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    3rd June 2012
    Posts
    12

    Re: Comment Out VBA Code Blocks

    A few days short of 10 years after the original post & you are my new hero. Hours of future frustration gone in a flash...

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    17th May 2008
    Posts
    13

    Re: Comment Out VBA Code Blocks

    This deserves another bump. Thanks so much!!!!

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Macro Code To Add Cell Comment
    By Furion in forum EXCEL HELP
    Replies: 4
    Last Post: June 17th, 2008, 01:56
  2. Add Cell Comment via Code
    By Malhar in forum EXCEL HELP
    Replies: 4
    Last Post: August 18th, 2006, 14:40
  3. Commenting out blocks of code
    By laz272 in forum EXCEL HELP
    Replies: 3
    Last Post: May 13th, 2006, 01:42
  4. Placing Cell Comment from VB Code
    By Warderbrad in forum EXCEL HELP
    Replies: 1
    Last Post: March 24th, 2006, 05:40
  5. Comment/Explain VBA Code
    By booger in forum EXCEL HELP
    Replies: 5
    Last Post: November 5th, 2005, 01:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno