Sub Test()
Dim Arrêté As Date, TRés(), L As Long, Code As SsGr, Capital As Currency, _
Rembour As Currency, Détail, LaDate As Date, Montant As Currency, Pctage As Double, NbJrAn As Double
Arrêté = [C1].Value
ReDim TRés(1 To 5000, 1 To 26)
L = -1
For Each Code In Gigogne(TableUnique(Feuil4.[A2:C2], _
TabCols(Feuil5.[A2:C2], 2, 1, 3), Feuil2.[A2:C2], _
Feuil3.[A2:C2]), 1, Null, 2)
L = L + 1: Capital = 0: Rembour = 0
For Each Détail In Code.Co
Select Case Détail(0)
Case 0: Pctage = Détail(3)
Case 1: NbJrAn = Détail(3)
Case 2:
Case 3:
End Select
LaDate = Détail(2)
If LaDate > Arrêté Then
If Détail(0) = 2 Then TRés(L, 10) = Arrêté: Exit For
Else
Montant = Détail(3)
L = L + 1
TRés(L, 1) = Code.Id
TRés(L, 2) = Capital
If Détail(0) = 0 Then
TRés(L, 3) = LaDate
TRés(L, 4) = Montant
Capital = Capital + Montant
Else
TRés(L, 5) = LaDate
TRés(L, 6) = Montant
Montant = Montant + Rembour: Rembour = 0
If Montant > Capital Then
Rembour = Montant - Capital
Montant = Capital
End If
Capital = Capital - Montant
TRés(L, 7) = Montant
End If
TRés(L, 8) = Capital
TRés(L, 9) = Rembour
End If
Next Détail
Next Code
[L16].Resize(5000, 10).Value = TRés
End Sub