VBA Array LBound function

VBA Array Lower Bound(LBound) Function

Let us see about VBA arrays lower bound or LBound function in Excel VBA. The LBound function represents the lower bound value of an array. It returns the smallest subscript(Index) value of specified array. It helps to determine the existing an array starting size.

Syntax of the LBound Function

Here is the Syntax of the LBound Function in Excel VBA.

LBound(ArrayName,[Dimension])

Where ArrayName: It is a mandatory argument. The ArrayName argument represnts the name of an array.
Dimension: It is an optional parameter. The Dimension argument represents the dimension of an array.
VBA Array Lbound function

Example for VBA LBound Function in Excel

Let us see the example for VBA lower bound function in Excel.

'VBA LBound Function
Sub VBA_LBound_Function()

    'Declare an array variable
    Dim aNEWS As Variant
    
    'Define an Array values
    sWeekDays = Array("North", "East", "West", "South")
    
    'Find Array Lower Bound
    MsgBox "Array Lower Bound Value is :" & LBound(sWeekDays), vbInformation, "VBAF1"
        
End Sub

Here is the output screen shot of above macro.

VBA LBound function

Instructions to use Macro

Here are the instructions to use above macro in Visual basic editor.

  • Open Visual Basic Editor(VBE) by clicking Alt +F11
  • Go to code window by clicking F7
  • Copy above specified macro or procedure
  • Paste above copied code in code window
  • Run macro by clicking F5 or Run command
  • You can see output on the screen
  • Find above specified output screenshot.

Other Related VBA Arrays articles

You may also like the related VBA Array articles.

Back to VBA Arrays




Leave a Comment

Your email address will not be published. Required fields are marked *