USING THE IMMEDIATE WINDOW


While in break mode, or before running a procedure, you can execute any VBA statement in the Immediate window. (If the Immediate window isn’t visible, choose View, Immediate Window or press Ctrl+G.) For example, you can find out the value of a variable x by typing Print x in the Immediate window. (As a shortcut, you can type ?x. The question mark character is a synonym for Print in VBA.)

You can also use the Immediate window to monitor action in a procedure while that procedure is running. You do this by inserting Debug.Print statements into the procedure. The statement Debug.Print x, for example, displays the current value of x in the Immediate window.

The Immediate window can be a handy place to test VBA statements while you’re still wrestling with the syntax of this programming language. If you’re not sure that a particular statement will have the effect that you intend, you can try it out in the Immediate window and see what happens.