Ubound
Determines the value of the largest subscript for the ArrayDimension of the ArrayName provided in the argument. Ubound expects the required argument ArrayName to be a valid variable array name.
The optional argument ArrayDimension must be a whole long number indicating which dimension's lower bound is to be returned. Use 1 for the first dimension, 2 for the second, and so on. If ArrayDimensionis omitted, 1 is assumed.
Syntax
Ubound(ArrayName, ArrayDimension)
ArrayName:
A string or expression that can represent a valid variable array name.
ArrayDimension:
A numeric value or expression that can represent a valid long data type value.
Return Value
Returns a number of Long data type.
Related Functions
Example
Dim Upper
Dim MyArray(1 To 10, 5 To 15, 10 To 20) ' Declare array variables.
Dim AnyArray(10)
Upper = UBound(MyArray, 1) ' Returns 10.
Upper = UBound(MyArray, 3) ' Returns 20.
Upper = UBound(AnyArray) ' Returns 10.