VBA Array Length / Size

This tutorial will teach you how to get the length (size) of an Array in VBA.

Get Array Length

In order to get the length of an Array, you need to know the array’s start and end positions. You can do this with the VBA’s UBound and LBound Functions.

LBound and UBound Functions

This procedure demonstrates how to use the UBound and LBound Functions on a a single dimension array:

Subtracting the two will give you the array length (UBound – LBound +1).

Get Array Length Function

This function will calculate the size (length) of a single-dimensional Array:

Get 2D Array Size

This function will calculate the number of positions in a two-dimensional array:



VBA Code Examples Add-in

Easily access all of the code examples found on our site.

Simply navigate to the menu, click, and the code will be inserted directly into your module. .xlam add-in.

(No installation required!)