2016-11-24 92 views
0

如何獲得VBA(excel)中的二維數組的長度?如何獲得VBA(excel)中的二維數組的長度?

暗淡givenData(5,7)爲雙

我需要一個命令,將返回5, 和命令,將返回7.

+3

http://stackoverflow.com/questions/26644231/vba-using-ubound-on-a-multidimensional-array,http://www.excel-easy.com/vba/examples/ size-of-an-array.html – Slai

+0

https://msdn.microsoft.com/en-us/library/office/gg 264295.aspx – teddy2

回答

0
Sub ShowArrayBounds() 
    Dim givenData(3 To 5, 5 To 7) As Double 

    MsgBox LBound(givenData, 1) 
    MsgBox UBound(givenData, 1) 
    MsgBox LBound(givenData, 2) 
    MsgBox UBound(givenData, 2) 

End Sub 

您可以使用UBound-LBound + 1獲得「大小「爲每個維度