Option Explicit
Option Base 1
Sub MAIN()
Dim MON_TOTAL_LIGNE As Long
Dim MON_TOTAL_LIGNE_BD As Long
Dim x As Long, y As Long
Dim TdB, TdD, TdF
Dim TdA
Dim Test
Application.DisplayStatusBar = True
Application.Calculation = xlCalculationManual
MON_TOTAL_LIGNE = Sheets("Tableau de bord").[A60000].End(xlUp).Row
MON_TOTAL_LIGNE_BD = Sheets("Volume_Mag").[A60000].End(xlUp).Row
ReDim TdB(MON_TOTAL_LIGNE_BD - 1)
ReDim TdD(MON_TOTAL_LIGNE_BD - 1)
ReDim TdBxx(MON_TOTAL_LIGNE_BD - 1)
ReDim TdA(MON_TOTAL_LIGNE - 5, 3)
For x = 6 To MON_TOTAL_LIGNE
TdA(x - 5, 1) = Sheets("Tableau de bord").Range("A" & x)
Next
With Sheets("Volume_Mag")
TdB = .Range("B2:B" & MON_TOTAL_LIGNE_BD)
TdD = .Range("D2:D" & MON_TOTAL_LIGNE_BD)
TdF = .Range("F2:F" & MON_TOTAL_LIGNE_BD)
For y = 1 To MON_TOTAL_LIGNE_BD - 1
For x = 1 To MON_TOTAL_LIGNE - 5
If TdA(x, 1) = TdB(y, 1) Then
If TdD(y, 1) = 1 Then TdA(x, 2) = TdA(x, 2) + TdF(y, 1)
If TdD(y, 1) = 2 Then TdA(x, 3) = TdA(x, 3) + TdF(y, 1)
TdA(x, 1) = TdA(x, 1)
End If
Next
Test = CInt((y / MON_TOTAL_LIGNE_BD) * 100)
Application.StatusBar = "Progression de l'analyse : " & Round((y / MON_TOTAL_LIGNE_BD) * 100, 2) & "%"
DoEvents
Next
End With
With Sheets("Tableau de bord")
For x = 6 To MON_TOTAL_LIGNE
.Cells(x, 7) = TdA(x - 5, 3) / .Cells(x, 3)
.Cells(x, 9) = TdA(x - 5, 2) / .Cells(x, 3)
Next
End With
Application.StatusBar = False
Application.Calculation = xlCalculationAutomatic
End Sub