Microsoft Office Tutorials and References
In Depth Information
Dealing with Logical Errors
If you want the entire procedure to run slowly, you can set the breakpoint
in the first line of the procedure (the Sub or Function statement). To set
a breakpoint, right-click the line where you want to set the breakpoint and
then choose Toggle Breakpoint from the contextual menu, as shown in
Figure 6-3. The line where you set the breakpoint is highlighted in red and
has a large red dot to the left.
Figure 6-3:
Setting a
breakpoint.
You can also open the Locals window to watch the values of variables
change as the code is running in break mode. (After you set a breakpoint,
the code runs in break mode, or one line at a time.) To open the Locals
window, choose View Locals Window in Visual Basic Editor. Like other
windows in Visual Basic Editor, the Locals window can be docked to the Visual
Basic Editor program window or dragged away from the window border to
become free-floating.
After you set a breakpoint, just run the code normally. Before executing a
line of code, VBA highlights the line in yellow that’s about to execute and
shows an arrow to the left of that line. You have three choices at that point:
Book VIII
Chapter 6
To execute only the highlighted line, press F8 or choose Debug Step Into.
To skip the highlighted line without executing it, press Shift+F8 or
choose Debug Step Over.
To bail out of break mode, press Ctrl+Shift+F8 or choose Debug Step Out.
Some types of runtime errors cause VBA to go into break mode automatically.
You see the yellow highlight line when that happens.
Search JabSto ::




Custom Search