Skip to main content

Stop statement

Table of contents
  1. Syntax
  2. Remarks
  3. Examples

Suspends execution.




You can place Stop statements anywhere in procedures to suspend execution. Using the Stop statement is similar to setting a breakpoint in the code.

The Stop statement suspends execution, but unlike End, it doesn't close any files or clear variables, unless it is in a compiled executable (.exe) file.


This example uses the Stop statement to suspend execution for each iteration through the For...Next loop.

Dim i As Long
For i = 1 To 10 ' Start For...Next loop.
    Debug.Print i ' Print i to the Immediate window.
    Stop ' Stop during each iteration.
Next i

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>