I thought Excel VBA had a built in function which returned the number of dimensions to an array - but I can't find it in the online help. Is there such a function?
HedgePig
P.S. I wrote a little function myself but I really want to find the name of that built-in function!
Sub TestDimensionsCount()
Dim testarray(1, 2, 3)
MsgBox NumDims(testarray)
End Sub
'Returns the number of dimensions of the array parameter
Function NumDims(a As Variant) As Integer
If Not IsArray(a) Then
NumDims = 0
Exit Function
End If
NumDims = 1
On Error GoTo NoMoreDimsErr
Do
ub = UBound(a, NumDims)
NumDims = NumDims + 1
Loop
NoMoreDimsErr:
NumDims = NumDims - 1
On Error GoTo 0
End Function
HedgePig
P.S. I wrote a little function myself but I really want to find the name of that built-in function!
Sub TestDimensionsCount()
Dim testarray(1, 2, 3)
MsgBox NumDims(testarray)
End Sub
'Returns the number of dimensions of the array parameter
Function NumDims(a As Variant) As Integer
If Not IsArray(a) Then
NumDims = 0
Exit Function
End If
NumDims = 1
On Error GoTo NoMoreDimsErr
Do
ub = UBound(a, NumDims)
NumDims = NumDims + 1
Loop
NoMoreDimsErr:
NumDims = NumDims - 1
On Error GoTo 0
End Function