Sub Chgt()
Dim TbInt(), DicTamp As Dictionary, RngTest As Range, Cln As Collection, TDon(), CodeSap As SsGr, TTamp(), LTmp As Long, Détail, LDét As Long, TRés(), C As Integer
Set DicTamp = MGigogne.DicoGig(Gigogne(WshTamp.[A7:J7], 4))
Set RngTest = ColUti(WshTest.[A5:F5], True)
Set Cln = Gigogne(WshTest.[A5:F5], 1)
ReDim TRés(1 To RngTest.Rows.Count, 1 To 9)
MGigogne.GarderOrdreInitial TDon, RngTest
For Each CodeSap In Gigogne(WshTest.[A5:F5], 1)
If DicTamp.Exists(CodeSap.Id) Then
TTamp = DicTamp(CodeSap.Id): LTmp = 1
For Each Détail In CodeSap.Co
LDét = Détail: C = 2
Do While LTmp <= UBound(TTamp, 1)
If TRés(LDét, 1) + TTamp(LTmp, 7) > TDon(LDét, 6) Then Exit Do
TRés(LDét, 1) = TRés(LDét, 1) + TTamp(LTmp, 7)
TRés(LDét, 2) = TDon(LDét, 6) - TRés(LDét, 1)
If UBound(TRés, 2) < C + 5 Then ReDim Preserve TRés(1 To UBound(TRés, 1), 1 To C + 5)
TRés(LDét, C + 1) = TTamp(LTmp, 2)
TRés(LDét, C + 2) = TTamp(LTmp, 3)
TRés(LDét, C + 3) = TTamp(LTmp, 6)
TRés(LDét, C + 4) = TTamp(LTmp, 7)
TRés(LDét, C + 5) = TTamp(LTmp, 10)
C = C + 6: LTmp = LTmp + 1: Loop
Next Détail
End If
Next CodeSap
WshTest.[G5].Resize(1000000, 10000).ClearContents
WshTest.[G5].Resize(UBound(TRés, 1), UBound(TRés, 2)).Value = TRés
End Sub