Skip to content

VBA009 — Unreachable code

Severity: 🟡 warning Category: control_flow Phase: 0

Description

Code follows an unconditional Exit / GoTo / End and can never run.

Failing example

Sub S()
    Exit Sub
    Debug.Print 1
End Sub

Compliant example

Sub S()
    Debug.Print 1
    Exit Sub
End Sub

How to fix

Remove the dead code or move it before the unconditional jump.


Source: src/rules.py — entry VBA009.