length of array
-
-
-
Re: length of array
Hi Aadarsh,
Try this:
[vba]
Ubound(array)
[/vba]HTH.
-
Re: length of array
Thanx
-
Re: length of array
The above solution doesn't work for zero-based arrays. Here's a complete example.
Code- Option Base 0 'Un-comment for zero-based arrays
- 'Option Base 1 'Un-comment for one-based arrays
- Sub ShowArrayLen()
- Dim abcarray() As Variant
- ReDim abcarray(3) 'i.e. some run-time array size value
- MsgBox "Range: " & LBound(abcarray) & " to " & UBound(abcarray)
- MsgBox "Length: " & UBound(abcarray) - LBound(abcarray) + 1
- MsgBox "Ubound: " & UBound(abcarray) 'does not = length for zero-based arrays!
- End Sub