Option Base 1

All arrays will start at zero unless they are explicitly defined to start at another number.
All arrays start at 0. by default
You can also use the "Option Base 1" declaration at the top of the module to change the default to 1 instead of 0.
This statement only affects the module it is declared in.

Option Base 1 

Dim arValues(50) As String

This will create an array containing 51 items.
This only affects the lower bounds of variables declared in the module where it is defined.
The default lower bound can also be changed to any other number by using the "To" keyword in the declaration.

Dim arValues(0 To 10) As String 


Always define both the boundaries of an array. Never use the Option Base setting.


Excel Ranges Use Base 1

When an array is populated straight from a range the array will start at 1 and not 0.
For more information refer to the Cells & Ranges > Working With Arrays


Important

This can only be changed on a per module basis.
If you have more than one module containing array manipulations you need to add this statement to the top of every code module.


© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

Top

PrevNext