thanks, I was changed. but I Not understand "Visual Basic for Applications arrays can have up to 60000"
For 1 To 60000, Is it need? If normal around <20 dimensions, Set 99 Is it enough?
any advice please!
Code:
Private Sub Command1_Click()
Dim myArr(0 To 99, 0 To 2, 0 To 6) As String
Debug.Print FindNumberOfDimensions(myArr), Time
End Sub
Public Function FindNumberOfDimensions(ByRef Xarray() As String, _
Optional ByVal aroundDimension As Long = 9) As Long
'Dimensions Xarray as an array.
'Dim Xarray(1 To 10, 5 To 20, 256 To 300, 8, -5 To 0)
'Sets up the error handler.
On Error GoTo FinalDimension
'Visual Basic for Applications arrays can have up to 60000
'dimensions; this allows for that.
For DimNum = 1 To aroundDimension
'It is necessary to do something with the LBound to force it
'to generate an error.
ErrorCheck = LBound(Xarray, DimNum)
Next DimNum
'FindNumberOfDimensions = DimNum
Exit Function
'The error routine.
FinalDimension:
MsgBox "The array has " & DimNum - 1 & " dimensions"
'return result:
FindNumberOfDimensions = DimNum - 1
End Function