Excelogist

 

如果获取VBA数组的维数

如何用VBA代码获得数组具有多少维数

使用以下自定义函数即可:

Public Function NumberOfDimensions(ByRef arrRef As Variant) As Integer
    Dim DimCount As Byte, j%
    DimCount = 0
    On Error GoTo ErrHandler
    For j = 1 To 128
        DimCount = DimCount + VBA.Abs(VBA.IsNumeric(UBound(arrRef, j)))
    Next j
    Exit Function
ErrHandler:
        Err.Clear
        NumberOfDimensions = DimCount
End Function

posted on 2023-03-19 15:19  Excelogist  阅读(98)  评论(0)    收藏  举报

导航