Skip to content

VBA151 — Code after End Sub/Function/Property

Severity: 🔴 error Category: syntax Phase: 2.12

Description

Only comments may appear after End Sub, End Function, or End Property on the same line.

Failing example

Sub S()
End Sub: x = 1

Compliant example

Sub S()
End Sub   ' done

How to fix

Move the trailing statement to its own line.


Source: src/rules.py — entry VBA151.