So we can see in the above screenshot that the green statements will not be executed by the macro and will only be treated as comments block. In doing so, the highlighted statements that commented would now turn into executable statements of the code or procedure and change in color from green to black again as below:.
Below you can find some useful excel VBA articles —. Forgot Password? These are suggestions; Visual Basic does not enforce rules for adding comments. Write what works best, both for you and for anyone else who reads your code. Every important variable declaration should be preceded by a comment describing the use of the variable being declared. Variables, controls, and procedures should be named clearly enough that commenting is needed only for complex implementation details.
You can add or remove comment symbols for a block of code by selecting one or more lines of code and choosing the Comment and Uncomment buttons on the Edit toolbar.
You can also add comments to your code by preceding the text with the REM keyword. Skip to main content. This browser is no longer supported. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings. Rather than have to type an apostrophe before every line of code, you can select a block of code and comment it out :.
The easiest way by far to comment out code is using the Edit toolbar:. Right-click on any toolbar in VBA and tick the Edit toolbar to display it. Not Helpful 0 Helpful 0. Include your email address to get a message when this question is answered.
By using this service, some information may be shared with YouTube. Use white space. Many programmers choose to separate out comments, code modules and procedures, and more through the use of hitting return and using white space in the overall code document.
It's important to recognize that the white space will not be read by the machine. Like comments themselves, it is simply a way to improve how the code looks to the human eye. Helpful 0 Not Helpful 0. Submit a Tip All tip submissions are carefully reviewed before being published. You Might Also Like How to. How to. Co-authors: 9. Updated: November 16, Categories: Programming.
Thanks to all authors for creating a page that has been read 45, times. Is this article up to date? Cookies make wikiHow better. By continuing to use our site, you agree to our cookie policy.
About This Article. Featured Articles How to. Trending Articles How to.
0コメント