
Place at the Top of the Module
The Option Base statement must be placed before any procedures in a module, typically at the very top. It’s a declaration statement and affects all the arrays declared in the module.Syntax
There are two options:- Option Base 0: This is the default setting. Arrays will start at index 0.
- Option Base 1: Arrays will start at index 1.
Scope
The Option Base statement only affects arrays declared in the same module. Each module can have its own Option Base setting.Examples
Without Option Base or with Option Base 0:VBA
With Option Base 1:
Dim myArray(5) As Integer
' myArray is indexed from 0 to 5
VBA
Option Base 1
Dim myArray(5) As Integer
' myArray is indexed from 1 to 5