Execute a Specific Statement
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Execute a Specific Statement

This page is specific to the Visual Basic for Applications (VBA) Language Reference for Office 2010.

While execution of your code is halted, you can control the execution sequence of statements within a procedure. You can resume execution at a statement you choose without executing any intervening code.

To set the next statement to be executed

  1. In the Code window, position the insertion point anywhere within the statement.

  2. On the Debug menu, click Set Next Statement (CTRL+F9). – or on Windows – Position the mouse pointer in the margin indicator next to the current execution point.

  3. Drag the yellow arrow in the margin indicator to the statement you want to execute next.

    NoteNote

    You can only skip to statements within the same procedure.

    Used in combination with Step Into, executing specific statements with the Set Next Statement command enables you to step through procedures one statement at a time, and to closely examine your code. It's also helpful for correcting or avoiding run-time error conditions.

Show:
© 2016 Microsoft