UBound Function

Returns the largest available subscript for the indicated dimension of an array.

                      UBound(arrayname[, dimension])

Arguments

  • arrayname
    Required. Name of the array variable; follows standard variable naming conventions.

  • dimension
    Optional. Whole number indicating which dimension's upper bound is returned. Use 1 for the first dimension, 2 for the second, and so on. If dimension is omitted, 1 is assumed.

Remarks

The UBound function is used with the LBound Function to determine the size of an array. LBound returns 0 because the lower bound for any dimension is always 0. Therefore, the length of a dimension is one greater than the output of the UBound function.

The following table shows the values returned by various UBound statements when they are applied to an array that has these dimensions:

Dim A(100,5,4)

Statement

Return value

UBound(A, 1)

100

UBound(A, 2)

5

UBound(A, 3)

4

Requirements

Version 1

See Also

Reference

Dim Statement

LBound Function

ReDim Statement

Array Function

IsArray Function

Private Statement

Public Statement

Erase Statement

Change History

Date

History

Reason

September 2009

Added information to Remarks.

Customer feedback.