Using the Immediate Window

The Immediate window is a sort of VBA programmer's scratch pad. Here you can test VBA instructions before putting them to work in your VBA procedures. It is a great tool for experimenting with your new language. Instructions that you enter in this window immediately display results. To activate the Immediate window, switch to the Visual Basic Editor window and choose View | Immediate Window.

The Immediate window can be moved anywhere on the Visual Basic Editor screen, or it can be docked so that it always appears in the same area of the screen. The docking setting can be turned on and off from the Docking tab in the Options window (Tools | Options). To access the Immediate window, press Ctrl+G while in the Visual Basic Editor screen. To close the Immediate window, click the Close button in the top right corner of the window.

The Immediate window allows you to type VBA statements and test their results immediately without having to write a procedure. Use it to try out your statements. If the statement produces the expected result, you can copy the statement from the Immediate window into your procedure (or you can drag it right onto the Code window, if it is visible).

The following hands-on demonstrates how to use the Immediate window to check instructions and get answers.

0 0

Post a comment