Querying Anything While Stepping Through Code

We haven't talked about variables yet (the macro recorder never records a variable), but you can query the value of anything while in step mode.

Using the Immediate Window

Press Ctrl+G to display the Immediate window in the VB Editor. While the macro is in break mode, you can ask the VB Editor to tell you the currently selected cell, the name of the active sheet, or the value of any variable. Figure 2.26 shows several examples of queries typed into the Immediate pane.

Figure 2.26

Queries (and their answers),which can be typed into the Immediate window while a macro is in break mode.

Figure 2.26

Queries (and their answers),which can be typed into the Immediate window while a macro is in break mode.

When invoked with Ctrl+G, the Immediate window usually appears at the bottom of the code window. You can use the resize handle (above the blue Immediate title bar) to make the Immediate window larger or smaller (see Figure 2.27).

Figure 2.27

Resizing the Immediate window.

Figure 2.27

Resizing the Immediate window.

0 0

Post a comment