Excel like a finance pro.
VBA · Errors & debugging
Debug.Print and the Immediate window
Writes values to the Immediate window (Ctrl + G) while code runs.
When to use it
Debug.Print writes to the Immediate window (Ctrl + G in the editor) while code runs. It is the quickest way to see what a variable holds without stopping.
The code
- Code
Debug.Print "row", i, Cells(i, 1).Value
Worked examples
Trace a loop
Debug.Print "row", i, Cells(i, 1).Value → A line per iteration in the Immediate window
Commas add tabs.
Ask a question
?Range("A1").Value ' typed in the Immediate window → Prints the value immediately
Ad hoc checks.
Timing
Debug.Print Timer - t0 & " seconds" → Timing a macro
Find slow parts.
Worth knowing
- The Immediate window holds about 200 lines; older output scrolls away.
- Leave Debug.Print lines in; they cost nothing when the window is closed.
- Debug.Assert stops when a condition is False.
Where it goes wrong
- Output to the Immediate window is slow inside huge loops.
- Ctrl + G in Excel (not the editor) is Go To, a different thing.
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.