Skip to content

VBA008 — Exit statement type mismatch

Severity: 🔴 error Category: control_flow Phase: 0

Description

Exit Sub used inside a Function (or vice versa).

Failing example

Function F() As Long
    Exit Sub
End Function

Compliant example

Function F() As Long
    Exit Function
End Function

How to fix

Use the matching Exit form for the procedure type.


Source: src/rules.py — entry VBA008.