Sub essai2()
Dim Tableau(1 To 10, 1 To 9, 1 To 12) ' 10 lignes/9 colonnes
Dim y As Integer, x As Integer, z As Integer
For y = LBound(Tableau, 1) To UBound(Tableau, 1)
For x = LBound(Tableau, 2) To UBound(Tableau, 2)
For z = LBound(Tableau, 3) To UBound(Tableau, 3)
Tableau(y, x, z) = Sheets(z).Cells(y, x)
Next z
Next x
Next y
MsgBox SommeTableau(Tableau, Empty, 1, 4) ' Colonne 1
MsgBox SommeTableau(Tableau, 2, Empty, 4) ' Ligne 2
MsgBox SommeTableau(Tableau, 1, 1, Empty) ' toutes les feuilles
MsgBox SommeTableau(Tableau, 3, 2, 1)
End Sub
Function SommeTableau(T(), Lig, Col, F)
If IsEmpty(Col) Then
For x = LBound(T, 2) To UBound(T, 2)
temp = temp + T(Lig, x, F)
Next x
Else
If IsEmpty(Lig) Then
For y = LBound(T, 1) To UBound(T, 1)
temp = temp + T(y, Col, F)
Next y
Else
If IsEmpty(F) Then
For z = LBound(T, 3) To UBound(T, 3)
temp = temp + T(Lig, Col, z)
Next z
Else
temp = T(Lig, Col, F)
End If
End If
End If
SommeTableau = temp
End Function