Excel like a finance pro.
VBA · Syntax
Comments
An apostrophe starts a comment that VBA ignores.
When to use it
An apostrophe starts a comment that runs to the end of the line. Comments explain why the code does something; the code itself shows what.
The code
- Code
' This line is a comment
Worked examples
Explain intent
' Rates are quarterly, so divide by 4 → Explains an otherwise puzzling division
The why, not the what.
Trailing comment
total = total + x ' running sum → A comment after code on the same line
Short trailing notes.
Comment out a block
Select the lines, Edit toolbar > Comment Block → Every selected line gets an apostrophe
Disable code temporarily.
Worth knowing
- Put a header comment on each procedure: purpose, inputs, and date.
- The Edit toolbar (View > Toolbars) has Comment and Uncomment Block buttons.
- Rem also starts a comment but nobody uses it.
Where it goes wrong
- Commented-out code left for months confuses everyone; delete it.
- An apostrophe inside a string is not a comment, but one after a string is.
Related
Learn the moves here — or let Wauvel run them on your numbers.
Meet your AI CFO →One CFO-grade Excel tip a week
A short, practical email for finance operators — functions, shortcuts, and the moves that save an afternoon. Free, unsubscribe anytime.