This quick how to tip shows you how to add comments to your VBA code.
Add comments to your VBA code
VBA is short for Visual Basic for Applications. Overall, it is the coding language for Office apps.
To make your code more readable, we suggest placing comments in your code. The image below illustrates the two methods for placing a comment in VBA. In old versions of BASIC, they also referred to it as a remark.
So, there are two ways to add comments in VBA.
- Firstly, you can use the Rem statement to add a comment in VBA. Keep in mind, you use Rem for single line remarks. You cannot use Rem on the same line as other VBA code.
- Secondly, the apostrophe (‘) starts a comment string in VBA. It is the shortcut method. Also, as you see from the above image, it is also our preferred method. In addition, you can use the apostrophe on a single line. Or, on the same line as your code.
By the way, Rem is short for Remark. It comes from the original BASIC language.
That is all to it. Enjoy!