Microsoft Office Tutorials and References
In Depth Information
Figure 4-11. The Add Watch dialog box
The Locals window shows the values of all local variables. A local variable is a variable defined
within the current procedure, and is therefore not valid in any other procedure. (We will discuss
local variables in the next chapter.)
The Watches window shows all of the watches that we have set. A watch is a variable or
expression that we place in the Watch window. Excel automatically updates the expressions in the
Watch window after each line of code is executed and acts according to the type of watch defined,
as described in the following list.
To add a watch, choose Add Watch from the Debug menu. This will produce the dialog box
shown in Figure 4-11 . We can then enter a variable or expression, such as x > 6 , in the Expression
text box. Note that there are three types of watches:
Watch Expression simply adds the expression to the Watches window, so we can watch
its value as code is executed. In this example, the value of the expression will be either
True or False , depending upon whether x is greater than 6 .
Break When Value Is True asks Excel to stop execution and enter break mode whenever
the expression is true . In this example, VBA will break execution when x > 6 is true ,
that is, when x becomes greater than 6 .
Break When Value Changes asks Excel to enter break mode when the value of the
expression changes in any way. (In this case, from True to False or vice-versa.)
Figure 4-11. The Add Watch dialog box
 
Search JabSto ::




Custom Search