Skip to content

VBA320 — Module is missing Option Explicit

Severity: 🟡 warning Category: style Phase: 3.6

Description

Without Option Explicit typo'd variable names silently create new Variant variables — the #1 source of typo-induced bugs in VBA, and a common AI-generation pitfall.

Failing example

Sub S()
    typo = 1
End Sub

Compliant example

Option Explicit
Sub S()
    Dim count As Long
    count = 1
End Sub

How to fix

Add Option Explicit as the first non-comment line of the module.


Source: src/rules.py — entry VBA320.