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
| Private Sub CommandButton1_Click()
Sheets("Echéancier").Activate
' L est le numéro de ligne du Tiers
Dim L As Integer
' Rechercher la ligne du Tiers à mettre à jour
Ct = WorksheetFunction.CountA(Range("A:a"))
Cells(1, 14) = Ct
For i = 2 To Ct
If Cells(i, 5) = Tiers.Value Then
L = i
Cells(2, 14) = L
Exit For
Else
L = 0
End If
Next
If L = 0 Then
' Sortir de la macro si le tiers n'existe pas
MsgBox ("Pas de tiers à ce nom")
Exit Sub
End If
Sheets("Base de données").Activate
Dim W As Integer 'Nb lignes dans la BDD
W = WorksheetFunction.CountA(Range("b:b"))
Cells(W + 1, 2) = Sheets("Echéancier").Cells(L, 1).Value 'Date
Cells(W + 1, 3) = Sheets("Echéancier").Cells(L, 2).Value 'Débit
Cells(W + 1, 4) = Sheets("Echéancier").Cells(L, 3).Value 'Crédit
Cells(W + 1, 6) = Sheets("Echéancier").Cells(L, 4).Value 'Souscat
Cells(W + 1, 7) = Sheets("Echéancier").Cells(L, 5).Value 'Tiers
Cells(W + 1, 8) = Sheets("Echéancier").Cells(L, 6).Value 'Mode de paiement
Cells(W + 1, 10) = Sheets("Echéancier").Cells(L, 7).Value 'Compte
Cells(W + 1, 11) = Sheets("Echéancier").Cells(L, 8).Value 'Commentaire
'Activer la feuille d'échéancier
Sheets("Echéancier").Activate
'Changer la date
Dim A As Integer
Dim B As Integer
A = 31
B = 30
If Cells(L, 10) = 1 Then
****Cells(L, 1) = Cells(L, 1).Value + A
ElseIf Cells(L, 10) = 2 Then
****Fev = InputBox("Combien de jours en février cette année ?", "Février", "28")
****Cells(L, 1) = Cells(L, 1).Value + Fev
ElseIf Cells(L, 10) = 3 Then
****Cells(L, 1) = Cells(L, 1).Value + A
ElseIf Cells(L, 10) = 4 Then
****Cells(L, 1) = Cells(L, 1).Value + B
ElseIf Cells(L, 10) = 5 Then
****Cells(L, 1) = Cells(L, 1).Value + A
ElseIf Cells(L, 10) = 6 Then
****Cells(L, 1) = Cells(L, 1).Value + B
ElseIf Cells(L, 10) = 7 Then
****Cells(L, 1) = Cells(L, 1).Value + A
ElseIf Cells(L, 10) = 8 Then
****Cells(L, 1) = Cells(L, 1).Value + A
ElseIf Cells(L, 10) = 9 Then
****Cells(L, 1) = Cells(L, 1).Value + B
ElseIf Cells(L, 10) = 10 Then
****Cells(L, 1) = Cells(L, 1).Value + A
ElseIf Cells(L, 10) = 11 Then
****Cells(L, 1) = Cells(L, 1).Value + B
ElseIf Cells(L, 10) = 12 Then
****Cells(L, 1) = Cells(L, 1).Value + A
End If
Unload Echeancier
End Sub
Sub LancerUserform()
Echeancier.Show
End Sub |
Partager