The Immediate Window

The Immediate window (see Figure 3-1) has two main functions. First, we can send output to this window using the command Debug.Print. For instance, the following code will print whatever text is currently in cell A1 of the active worksheet to the Immediate window:

Debug.Print ActiveSheet.Range("A1").Text

This provides a nice way to experiment with different code snippets.

The other main function of the Immediate window is to execute commands. For instance, by selecting some text in the active document, switching to the Immediate window, and entering the line shown in Figure 3-9, the selected text will be boldfaced (after hitting the Enter key to execute the code).

Figure 3-9. The Immediate Window

Figure 3-9. The Immediate Window

The Immediate window is an extremely valuable tool for debugging a program, and you will probably use it often (as I do).

0 0

Post a comment