1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| Sub Macro1()
'
' Macro1 Macro
'
'
' Actions in List Al Ech Sheet
Sheets("List Al Ech").Select
' Nombre de Lignes
Dim nb_lignes As Long
nb_lignes = WorksheetFunction.CountA(Range("A:A"))
'MsgBox "Nombre d'enregistrement : " & nb_lignes
Dim CIN As Long
Dim Account As String
Dim Period As Integer
Dim RepaymentDate As Date
Dim TotalDue As Double
Dim TotalRbtCcp As Double
Dim TotalRbtEsp As Double
Dim TotalRBT As Double
Dim CapitalRestant As Double
Dim DateDebutArriere As Date
Dim DateTraitement As Date
DateTraitement = Now
'MsgBox DateTraitement
Dim EnArriere As Boolean
Dim numero_ligne As Long
' Boucle sur toutes les lignes
For i = 2 To nb_lignes
'For i = 2 To 1000
'If IsNumeric(Range("A2")) Then
numero_ligne = i
'MsgBox "numero ligne : " & numero_ligne
If numero_ligne >= 2 And numero_ligne <= nb_lignes Then
CIN = Cells(numero_ligne, 1)
Account = Cells(numero_ligne, 2)
Period = Cells(numero_ligne, 3)
RepaymentDate = Cells(numero_ligne, 4)
TotalDue = Cells(numero_ligne, 5)
TotalRbtCcp = Cells(numero_ligne, 9)
TotalRbtEsp = Cells(numero_ligne, 10)
TotalRBT = Cells(numero_ligne, 11)
CapitalRestant = Cells(numero_ligne, 12)
' Si Period
If Period = 1 Then
' Period = 1
Cells(numero_ligne, 12).Value = TotalRBT - TotalDue
EnArriere = False
Else
' Period <> 1
Cells(numero_ligne, 12).Value = Cells(numero_ligne - 1, 12) - TotalDue
End If
'MsgBox "Capital restant = " & CapitalRestant
If CapitalRestant < -2 And EnArriere = False Then
'Recup Date
DateDebutArriere = Cells(numero_ligne, 4)
'MsgBox DateDebutArriere
Cells(numero_ligne, 13).Value = DateDebutArriere
EnArriere = Truev
Dim Found As Range
Dim Indice As Long
With Worksheets("main")
Set Found = .Range("F2:F4000").Find(Account, LookIn:=xlValues, LookAt:=xlWhole)
If Not Found Is Nothing Then
Indice = Found.Row
MsgBox Indice
.Cells(Indice, 1).Value2 = DateDebutArriere
End If
End With
End If
'MsgBox "CIN = " & CIN & ", " & "Account = " & Account & ", " & "Period = " & Period & ", " & "Repayment Date = " & RepaymentDate
Else
MsgBox "Error 1-1"
End If
'Else
' MsgBox "Error 1"
'End If
Next
'For i = 2 To 5
'For i = 1 To nb_lignes
'CIN = Cells(i, 1)
'MsgBox "CIN = " & CIN
'Next
End Sub |
Partager