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

8 thoughts on “VBA Array UBound Function in Excel”

  1. It is tгuly a great and useful piece of info. I’m satisfied that you simply shared this helpful information with
    us. Pleaѕe keep us up to date like this. Thank y᧐u fοr sharing.

  2. accountant freelancer

    I used to be suggested this website via my cousin. I am now not sure whether or not this put up
    is written via him as no one else recognize such specified about my difficulty.

    You’re incredible! Thank you!

  3. Pingback: Neha

  4. Pingback: Google

Leave a Comment