VBA Array UBound function

VBA Array Upper Bound(UBound) Function

Let us see about VBA arrays Upper Bound or UBound function in Excel VBA. The UBound function represents the Upper Bound value of an array. It returns the highest subscript(Index) value of specified array. It helps to determine the existing an array end size.

Syntax of the UBound Function

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


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 Ubound function

Example for VBA UBound Function in Excel

Let us see the example for VBA Upper Bound function in Excel.

'VBA UBound Function
Sub VBA_UBound_Function()

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

Here is the output screen shot of above macro.

VBA UBound 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

1 thought on “VBA Array UBound Function in Excel”

Leave a Comment

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