How to return the number of dimensions of a (Variant) variable passed to it in VBA

Viewed 83977

Does anyone know how to return the number of dimensions of a (Variant) variable passed to it in VBA?

10 Answers

I like to use the fact that with an error, the new variable-value is not charged.

To get the dimension (A_Dim) of an Array (vArray) you can use following code:

On Error Resume Next
    A_Dim = -1
    Do Until A = "X"
        A_Dim = A_Dim + 1
        A = "X"
        A = UBound(vArray, A_Dim + 1)
    Loop
On Error GoTo 0
Related