The VBA LBound function returns the lowest subscript for a dimension of a supplied array.
The syntax of the function is:
Where the function arguments are:
|[Dimension]||-||[Dimension] is omitted, it takes on the default value 1.If|
' Return the lowest subscript of a one-dimensional array.
Dim prices(0 to 10) As Double
Dim pricesLB As Integer
pricesLB = LBound( prices )' Now the integer pricesLB has the value 0.
After running the above VBA code, the variable pricesLB has the value 0.
' Return the lowest subscripts of each dimension a 2-d array.
Dim costs(0 to 10, 1 to 100) As Double
Dim costsLB1 As Integer
Dim costsLB2 As Integer
costsLB1 = LBound( costs, 1 )' Now, costsLB1 = 0 and costsLB2 = 1.
costsLB2 = LBound( costs, 2 )
After running the above VBA code, the variable costsLB1 has the value 0 and the variable costsLB2 has the value 1.