Hi kdw,
kdw wrote:
Is there any way to check for how many dimensions an array have? For
example, I can use ubound(TempArray,1), ubound(TempArray,2), etc.
But what if there is no 2nd dimension. My code would fail. I would
not want to loop through the column dimension if there isn't any so I
need some way to check for it.
I don't know of any built-in way to get the dimension count, but here's a
quick function that should do the job:
Public Function gnCountDimensions(rvArray As Variant) As Integer
Dim n As Integer
Dim lTemp As Long
Dim bFoundEnd As Boolean
Do While Not bFoundEnd
On Error Resume Next
lTemp = UBound(rvArray, n + 1)
If Err.Number Then
bFoundEnd = True
Else
n = n + 1
End If
On Error GoTo 0
Loop
gnCountDimensions = n
End Function
--
Regards,
Jake Marx
MS MVP - Excel
www.longhead.com
[please keep replies in the newsgroup - email address unmonitored]