Skip to content

VBA171 — Exit Do not within Do...Loop

Severity: 🔴 error Category: control_flow Phase: 2.11

Description

Exit Do is only valid inside a Do...Loop.

Failing example

Sub S()
    Exit Do
End Sub

Compliant example

Sub S()
    Do
        Exit Do
    Loop
End Sub

How to fix

Remove the Exit Do or place it inside a Do loop.


Source: src/rules.py — entry VBA171.