Comment Block Uncomment Block

The apostrophe placed at the beginning of a line of code denotes a comment. Besides the fact that comments make it easier to understand what the procedure does, comments are also very useful in testing and troubleshooting VBA procedures. For example, when you execute a procedure, it may not run as expected. Instead of deleting the lines of code that may be responsible for the problems encountered, you may want to skip these lines for now and return to them later. By placing an apostrophe at the beginning of the line you want to avoid, you can continue checking the other parts of your procedure. While commenting one line of code by typing an apostrophe works fine for most people, when it comes to turning entire blocks of code into comments, you'll find the Comment Block and Uncomment Block buttons on the Edit toolbar very handy and easy to use. To comment a few lines of code, select the lines and click the Comment Block button -. To turn the commented code back into VBA instructions, click the Uncomment Block button "2z.

If you don't select a block of text, when you click the Comment Block button the apostrophe is added only to the line of code where the cursor is currently located.

Part I

0 0

Post a comment