G Guest Feb 28, 2004 #1 Does anyone know how to check the number of dimensions of an already initialized array?
R Rob van Gelder Feb 28, 2004 #2 Sub test() Dim i As Long, j As Long Dim arr(1, 2, 3, 4) As Long On Error Resume Next i = 0 Do j = LBound(arr, i + 1) If Err.Number Then Exit Do Else i = i + 1 Loop Err.Clear On Error GoTo 0 MsgBox i End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel DigableP said: Does anyone know how to check the number of dimensions of an already Click to expand... initialized array?
Sub test() Dim i As Long, j As Long Dim arr(1, 2, 3, 4) As Long On Error Resume Next i = 0 Do j = LBound(arr, i + 1) If Err.Number Then Exit Do Else i = i + 1 Loop Err.Clear On Error GoTo 0 MsgBox i End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel DigableP said: Does anyone know how to check the number of dimensions of an already Click to expand... initialized array?
R Rob van Gelder Feb 28, 2004 #3 Smaller: Sub test() Dim arr(1, 2, 3, 4) As Long Dim i As Long On Error Resume Next Do: i = i - (LBound(arr, i + 1) * 0 = 0): Loop Until Err.Number On Error GoTo 0 MsgBox i End Sub
Smaller: Sub test() Dim arr(1, 2, 3, 4) As Long Dim i As Long On Error Resume Next Do: i = i - (LBound(arr, i + 1) * 0 = 0): Loop Until Err.Number On Error GoTo 0 MsgBox i End Sub