Excel like a finance pro.
VBA · Variables
Constants
A named value that cannot change, for settings used in many places.
When to use it
Const defines a named value that cannot change. Put settings like rates, sheet names, and column numbers at the top of a module so they are changed in one place.
The code
- Code
Const TAX_RATE As Double = 0.07
Worked examples
A setting
Const TAX_RATE As Double = 0.07 → A module-level rate used everywhere
Change once.
Sheet names
Const SHEET_DATA As String = "Data" Worksheets(SHEET_DATA).Activate → A sheet name in one place
Renaming the sheet means editing one line.
Column numbers
Const COL_AMOUNT As Long = 5 → A column number with a name
Cells(i, COL_AMOUNT) reads better than Cells(i, 5).
Worth knowing
- Upper case names are the convention.
- Public Const at module level shares across modules.
- Built-in constants like xlUp and vbYes are Consts too.
Where it goes wrong
- A Const cannot be assigned at runtime; use a variable if it must change.
- Const expressions must be literal, not function calls.
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.