Use the Immediate window

The Immediate window displays information resulting from debugging statements in your code or from commands typed directly into the window.

To display the Immediate window

  • From the View menu, choose Immediate window (CTRL+G).

To execute code in the Immediate window

  1. Type a line of code in the Immediate window.

  2. Press ENTER to execute the statement.

Use the Immediate window to:

  • Test problematic or newly written code.

  • Query or change the value of a variable while running an application. While execution is halted, assign the variable a new value as you would in code.

  • Query or change a property value while running an application.

  • Call procedures as you would in code.

  • View debugging output while the program is running.

Note

Immediate window statements are executed in a context—that is, as if they are entered in a specific module.

If you need help on syntax for functions, statements, properties, or methods while working in the Immediate window, select the keyword, the property name, or the method name, and press F1.

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.