Debug menu

Command Description Toolbar button Keyboard shortcut
Add Watch Displays the Add Watch dialog box in which you enter a watch expression. The expression can be any valid Basic expression. Watch expressions are updated in the Watch window each time you enter break mode. Add Watch toolbar button
Clear All Breakpoints Removes all breakpoints in your project. Your application may still interrupt execution, however, if you have set a watch expression or selected the Break on All Errors option on the General tab of the Options dialog box. You cannot undo the Clear All Breakpoints command. Clear All Breakpoints toolbar button CTRL+SHIFT+F9
Compile <project> Compiles your project. Compile project toolbar button
Edit Watch Displays the Edit Watch dialog box in which you can edit or delete a watch expression. Available when the watch is set even if the Watch window is hidden. Edit Watch toolbar button CTRL+W
Run to Cursor When your application is in design mode, use Run To Cursor to select a statement further down in your code where you want execution to stop. Your application will run from the current statement to the selected statement, and the current line of execution margin indicator (Run to cursor) appears on the Margin Indicator bar.

Use this command, for example, to avoid stepping through large loops.
CTRL+F8
Set Next Statement Sets the execution point to the line of code you choose. You can set a different line of code to execute after the currently selected statement by selecting the line of code you want to execute and choosing the Set Next Statement command, or by dragging the Current Execution Line margin indicator to the line of code that you want to execute.

Using Set Next Statement, you can choose a line of code located before or after the currently selected statement. When you run the code, any intervening code isn't executed. Use this command when you want to rerun a statement within the current procedure or to skip over statements you don't want to execute. You can't use Set Next Statement for statements in different procedures.
Set Next Statement toolbar button CTRL+F9
Show Next Statement Highlights the next statement to be executed. Use the Show Next Statement command to place the cursor on the line that will execute next. Available only in break mode. Show Next Statement toolbar button
Step Into Executes code one statement at a time.

When not in design mode, Step Into enters break mode at the current line of execution. If the statement is a call to a procedure, the next statement displayed is the first statement in the procedure.

At design time, this menu item begins execution and enters break mode before the first line of code is executed. If there is no current execution point, the Step Into command may appear to don'thing until you do something that triggers code, for example click on a document.
Step Into toolbar button F8
Step Over Similar to Step Into. The difference in use occurs when the current statement contains a call to a procedure. Step Over executes the procedure as a unit, and then steps to the next statement in the current procedure. Therefore, the next statement displayed is the next statement in the current procedure regardless of whether the current statement is a call to another procedure. Available in break mode only. Step Over toolbar button SHIFT+F8
Step Out Executes the remaining lines of a function in which the current execution point lies. The next statement displayed is the statement following the procedure call. All of the code is executed between the current and the final execution points. Available in break mode only. Step Out toolbar button CTRL+SHIFT+F8
Toggle Breakpoint Sets or removes a breakpoint at the current line. You can't set a breakpoint on lines containing nonexecutable code such as comments, declaration statements, or blank lines.

A line of code in which a breakpoint is set appears in the colors specified on the Editor Format tab of the Options dialog box.
Toggle Breakpoint toolbar button F9

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.