Sub Recopier_Liste_Decaissements()
Dim f1 As Worksheet, f5 As Worksheet
Dim DerLig_f1 As Long, DerLig_f5 As Long, i As Long
Dim Type_Dec As String, Montant_Dec As Double, Ech_Dec As String
Dim F As Range, t As Range, d As Range
Application.ScreenUpdating = False
Set f1 = Sheets("Tableau")
Set f5 = Sheets("Liste Décaissements")
DerLig_f1 = f1.Range("A" & Rows.Count).End(xlUp).Row
DerLig_f5 = f5.Range("A" & Rows.Count).End(xlUp).Row
For i = 4 To DerLig_f5
If f5.Cells(i, "I") <> "Oui" Then
Type_Dec = f5.Cells(i, "B")
Montant_Dec = f5.Cells(i, "E")
Ech_Dec = Format(Month(f5.Cells(i, "F")) & "-" & Year(f5.Cells(i, "F")), "mmm-yy")
Set F = f1.Cells.Find("FLUX DE DECAISSEMENTS", lookat:=xlWhole)
If Not F Is Nothing Then
Set t = f1.Range(f1.Cells(F.Row + 1, "A"), f1.Cells(DerLig_f1, "A")).Find(Type_Dec, lookat:=xlWhole)
If Not t Is Nothing Then
Set d = f1.Range(f1.Cells(F.Row + 1, "A"), f1.Cells(F.Row + 1, "O")).Find(Ech_Dec, lookat:=xlWhole)
If Not d Is Nothing Then
f1.Cells(t.Row, d.Column) = f1.Cells(t.Row, d.Column) + Montant_Dec
End If
End If
End If
End If
f5.Cells(i, "I") = "Oui"
Next i
f1.Select
Set F = Nothing
Set t = Nothing
Set d = Nothing
Set f1 = Nothing
Set f5 = Nothing
End Sub
Sub Recopier_Liste_Encaissements()
Dim f1 As Worksheet, f4 As Worksheet
Dim DerLig_f1 As Long, DerLig_f4 As Long, i As Long
Dim Type_Enc As String, Montant_Enc As Double, Ech_Enc As String
Dim F As Range, t As Range, d As Range
Application.ScreenUpdating = False
Set f1 = Sheets("Tableau")
Set f4 = Sheets("Liste Encaissements")
DerLig_f1 = f1.Range("A" & Rows.Count).End(xlUp).Row
DerLig_f4 = f4.Range("A" & Rows.Count).End(xlUp).Row
For i = 4 To DerLig_f4
If f4.Cells(i, "I") <> "Oui" Then
Type_Enc = f4.Cells(i, "B")
Montant_Enc = f4.Cells(i, "E")
Ech_Enc = Format(Month(f4.Cells(i, "F")) & "-" & Year(f4.Cells(i, "F")), "mmm-yy")
Set F = f1.Cells.Find("FLUX D'ENCAISSEMENTS", lookat:=xlWhole)
If Not F Is Nothing Then
Set t = f1.Range(f1.Cells(F.Row + 1, "A"), f1.Cells(DerLig_f1, "A")).Find(Type_Enc, lookat:=xlWhole)
If Not t Is Nothing Then
Set d = f1.Range(f1.Cells(F.Row + 1, "A"), f1.Cells(F.Row + 1, "O")).Find(Ech_Enc, lookat:=xlWhole)
If Not d Is Nothing Then
f1.Cells(t.Row, d.Column) = f1.Cells(t.Row, d.Column) + Montant_Enc
End If
End If
End If
End If
f4.Cells(i, "I") = "Oui"
Next i
f1.Select
Set F = Nothing
Set t = Nothing
Set d = Nothing
Set f1 = Nothing
Set f4 = Nothing
End Sub