30 Advanced Excel Tips for 2026

Excel Champs / VBA / VBA Immediate Window (Debug.Print)
By Puneet Gogia (Microsoft MVP)

VBA Immediate Window (Debug.Print)

30+ Advanced Excel Tips for 2026

No spam. Only Excel Stuff. God Promise. 😊

Press Ctrl + G in the Visual Basic Editor to open the Immediate window (or use View → Immediate Window). Type a line of code and press Enter to run it straight away, for example Range("A1").Value = 100.

Start a line with ? to see a result without writing a macro: ?Range("A1").Value, ?ActiveSheet.Name or ?Worksheets.Count. The ? shortcut works only in the Immediate window, not in a module.

In your code, Debug.Print writes to the Immediate window while the macro runs, which helps when checking values in a loop: Debug.Print i, Cells(i, 1).Value. A comma puts values in columns; a semicolon prints them side by side.

Type a macro’s name and press Enter to run it, or pass arguments, as in MyMacro 5, "East". When code is paused at a breakpoint or after F8, the window can read and change the current values of variables.

The window keeps only the last 200 lines. To clear it, click inside, press Ctrl + A, then Delete.

What is Immediate Window

Immediate Window is a small box in the Visual Basic Editor that you can use to execute a single line of code and get an instant result. In simple words, instead of running your whole code in Excel, you can run one line of a macro to see what it returns. It’s quite useful when you are debugging code.

When you open the Visual Basic Editor (Alt + F11), you can see the Immediate Window at the bottom.

vba-immediate-window

But if it’s not there, then you need to activate it from the View menu (View ➜ Immediate Window), or you can also use the keyboard shortcut key Control + G.

keyboard-shortcut-for-immediate-window

And if you want to undock it, click and hold the title bar and drop it outside of the VB editor.

click-and-hold-the-title-bar

What is Debug.Print

Debug.Print is a statement that you can use to show a value from your code in the Immediate Window. In simple words, when you use the Debug.Print command at the start of a line of code and then run the code, VBA shows the result of that line in the Immediate Window, without stopping the code.

Imagine you want to know which font color is applied to cell A1. In that case, you can use the following line of code, which starts with Debug.Print and then has the code to get the font color.

Debug.Print Range("A1").Font.Color

Now when you run this code, you get the result in the Immediate Window, like below. The font color comes back as a number, which is the RGB value of the color.

debug-print

Executing a Line of Code

Apart from using Debug.Print, you can directly execute a line of code from the Immediate Window. Let’s say you want to enter a value in cell A1; you can directly type the following code in the Immediate Window, and after that, hit ENTER.

executing-a-line-code

The Immediate Window executes a single line of code at a time. So, you need to hit Enter after each line of code that you want to run. To run more than one statement in one go, put them on one line and separate them with a colon (:).

Run a Macro Directly from the Immediate Window

You can also run a macro directly from the Immediate Window using the macro name. All you need to do is type the name of the macro and then hit Enter.

run-a-macro-directly

If the macro has arguments, make sure to type them after the name in the Immediate Window, separated by commas.

define-the-argument-within-immediate-window

Asking Quick Questions

You can also ask questions directly in the Immediate Window. What I’m trying to say is you can directly write a line of code in the Immediate Window and use a question mark to get the result. The question mark is a short way to write Print.

Let’s say you want to know the value that you have in cell A1. In that case, you can type the following line of code into the Immediate Window and hit Enter.

?Range("A1").Value
line-of-code-into-immediate-window

Print More Than One Value with Debug.Print

You can print several values in one line. A comma puts each value in its own column (a tab apart), and a semicolon prints them right next to each other. Using Debug.Print inside a loop is a quick way to see how a variable changes:

Sub debug_print_loop()
Dim i As Long
For i = 1 To 5
Debug.Print "Row"; i, Cells(i, 1).Value
Next i
End Sub

Check Variables While the Code Is Paused

When your code stops at a breakpoint or an error (break mode), the Immediate Window can see all the variables of that procedure. Type ? and the variable name, like ?i, to see its current value. You can even change a value, like i = 10, and then continue the code with F5.

Clear the Immediate Window

There’s no button to clear it. Click inside the Immediate Window (or press Ctrl + G), press Ctrl + A to select everything, and press Delete. Old lines also disappear on their own, as the window only keeps the last 200 lines or so.

Frequently Asked Questions

Why does Debug.Print show nothing?

The Immediate Window is probably closed, so press Ctrl + G in the VBA editor to open it. If it’s open and still empty, check that the line really runs, for example, that it isn’t inside an IF that is false.

Do I need to remove Debug.Print lines before sharing my code?

No, they don’t do anything for the user, as the result only goes to the Immediate Window. But removing them, or turning them into comments, keeps the code clean and a little faster in long loops.

What is the difference between Debug.Print and MsgBox?

MsgBox stops the code and waits for you to click OK, and the user sees it. Debug.Print doesn’t stop the code and only shows the value in the Immediate Window, which makes it better for checking values inside a loop.

Puneet Gogia

Written by

Puneet Gogia

Microsoft MVP — Excel · Founder, Excel Champs

Twelve years of teaching Excel, and a decade before that using it as a data analyst. Every tutorial here is written from a file I actually built.

3M+ readers helped
1,000+ tutorials written
Since 2015 teaching Excel