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 242 | Next

Jim DeMarco

"Pro Excel 2007 VBA"


The result is shown in Figure 7-23.
Figure 7-23. The Set Next Statement command moves the execution point to the
selected line of code.
CHAPTER 7 n DEBUGGING AND ERROR HANDLING 266
The Set Next Statement command can be used to move the execution point forward as
well as backward. You can also use the mouse to drag the execution arrow (shown in the gray
margin on the left side of the code window in Figure 7-23) to the location of the code you??™d like
to run.
nWarning The Set Next Statement command can be used to move the execution point backward or
forward in the code. It will not reverse values in a loop. If you need to see counters or incremented values
as they happen, remember to check them in their current context in a loop.
One last command you can use is the Run To Cursor command. The Run To Cursor command
lets you place the cursor on a line of code, and when that line is reached, the code will
resume break mode.
Let??™s bring the execution point to the cursor location as follows:
14. Put the cursor on the last line of code in the TestLoop function.
15. Choose Debug ?¤ Run To Cursor or press Ctrl+F8.
The execution point moves to the last line of code, as shown in Figure 7-24.
Figure 7-24. The Run To Cursor command moves the execution point to the cursor location.
Checking Variables in Break Mode
Our execution point is on the last line of code before the function is finished. Don??™t move the
execution point just yet. We have the ability in the VBE to view the values of variables in our
procedures as they change in real time.


Pages:
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254