2012年4月16日 星期一

VBA 二維陣列 2-Dimensional Array

Sub SampleArray()
    Dim Data(1 To 3, 1 To 4)
    Dim Sum As Single
    Dim iRow As Integer, iCol As Integer

    For iRow = LBound(Data, 1) To UBound(Data, 1)
        For iCol = LBound(Data, 2) To UBound(Data, 2)
            Data(iRow, iCol) = Cells(iRow, iCol)
            MsgBox "Data(" & iRow & "," & iCol & ") = " & Data(iRow, iCol)
            Sum = Sum + Data(iRow, iCol)
            MsgBox "Sum = " & Sum
        Next iCol
    Next iRow

    MsgBox "The final Sum = " & Sum
End Sub




Reference :
2-Dimensional Array - Excel 2003 VBA
2 dimensional array...Please help!

沒有留言:

張貼留言