Function TOTAL_LIGNE(Ma_Feuille As String, DEPART_LIGNE As Integer) As Integer 'Compter le nombre de ligne dans le tableau Donnees
Dim x As Integer
x = DEPART_LIGNE
Do While Sheets(Ma_Feuille).Cells(x, 1) <> ""
x = x + 1
Loop
TOTAL_LIGNE = x - DEPART_LIGNE
End Function
Sub MAIN()
Dim MON_TOTAL_LIGNE As Long
Dim MON_TOTAL_LIGNE_BD As Long
Dim x As Long, y As Long
Dim Val1, Val2 As Integer
Dim TdB1, TdB2
Dim TdB3
Application.DisplayStatusBar = True
MON_TOTAL_LIGNE = TOTAL_LIGNE("Tableau de bord", 6)
MON_TOTAL_LIGNE_BD = TOTAL_LIGNE("Volume_Mag", 2)
'ReDim TdB1(0 To MON_TOTAL_LIGNE - 1, 1 To 1)
'ReDim TdB2(0 To MON_TOTAL_LIGNE - 1, 1 To 1)
ReDim TdB3(0 To MON_TOTAL_LIGNE - 1, 0 To 2)
Do While x < MON_TOTAL_LIGNE
TdB3(x, 0) = Sheets("Tableau de bord").Cells(x + 6, 1)
x = x + 1
Loop
y = 0
x = 0
Do While y < MON_TOTAL_LIGNE_BD
Do While x < MON_TOTAL_LIGNE
If TdB3(x, 0) = Sheets("Volume_Mag").Cells(y + 2, 2) _
And Sheets("Volume_Mag").Cells(y + 2, 4) = 1 Then
TdB3(x, 1) = TdB3(x, 1) + Sheets("Volume_Mag").Cells(y + 2, 6)
Exit Do
End If
If TdB3(x, 0) = Sheets("Volume_Mag").Cells(y + 2, 2) _
And Sheets("Volume_Mag").Cells(y + 2, 4) = 2 Then
TdB3(x, 2) = TdB3(x, 2) + Sheets("Volume_Mag").Cells(y + 2, 6)
Exit Do
End If
x = x + 1
Loop
x = 0
y = y + 1
Application.StatusBar = y
Loop
Do While x < MON_TOTAL_LIGNE
Sheets("Tableau de bord").Cells(x + 6, 9) = TdB3(x, 1) / Sheets("Tableau de bord").Cells(x + 6, 3)
Sheets("Tableau de bord").Cells(x + 6, 7) = TdB3(x, 2) / Sheets("Tableau de bord").Cells(x + 6, 3)
x = x + 1
Loop
Application.StatusBar = False
Application.DisplayStatusBar = oldStatusBar
End Sub