SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 246 | Next

Jim DeMarco

"Pro Excel 2007 VBA"

Value variable, showing its value, N/A.
Figure 7-30. Checking variable values in the code window
Stop the code from running by clicking the Reset button on the toolbar, as shown in
Figure 7-31.
Figure 7-31. The Reset button stops code execution.
CHAPTER 7 n DEBUGGING AND ERROR HANDLING 271
Let??™s fix the error and rerun the code. On Sheet1 in Excel, change the value of cell D4 to 0,
or leave it blank and run the AddSalesTotal macro again. Figure 7-32 shows Sheet1 with the
total added after successfully running AddSalesTotal.
Figure 7-32. The worksheet after fixing the data
The Watch Window
The Watch window is a tool that allows you to set conditions on which you can put your code
into break mode. The Watch window, shown in Figure 7-33, has a few options as to how to
handle watched values.
Figure 7-33. The Watch window
You enter an expression in the Expression text box, and then select the context of the
expression from the Procedure and Module drop-down lists. Then you select a watch type.
Watch types are described in Table 7-3.
CHAPTER 7 n DEBUGGING AND ERROR HANDLING 272
Table 7-3.Watch Types
Watch Type Description
Watch Expression Code execution will not be stopped. In break mode, the values of
watched expressions will be displayed in the Watch window.
Break When Value Is True Code execution will enter break mode when the watched value is
True.
Break When Value Changes Code execution will enter break mode when the value of the
watched expression changes.


Pages:
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258