VBA LBound Function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

The Excel VBA LBound function returns a Long numeric value of the lower bounds (smallest subscript) of a VBA Array. This function is useful as in VBA you can define an array to start at any lower bound instead of 0 as in most programming languages.

VBA LBound Function Syntax


The name of the array variable (Variant data type).
Optional. The index number of the dimension for which the lower bounds are to be returned.

Example usage of VBA LBound function

Using LBound with single dimension arrays

In below example we will create 2 static VBA Arrays. The first array will be defined without explicitly setting it’s lower bounds. The second array will be defined with both lower and upper bounds.

LBound for multi-dimension arrays

In case dealing with multi-dimensional arrays you can use the dimension parameter to define for which dimension you want to obtains the VBA Array lower bounds:

Changing the default Array lower bounds

To reduce confusion around what is the lower bound of an array you can use the Options Base directive to set the default VBA Array default lower bounds. Let us revisit the code above:

Simply the best place to learn Excel VBA