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
| Option Explicit
Sub Effacer()
Feuil1.Range("G6,G8,G10,G14,G16,G19,G21,G23,G26,G28,G30,G34,L21:M22,M16").ClearContents
End Sub
Sub Enregistrer()
Dim Plage As Range, c As Range
Dim NewLig As Long
Dim i As Integer
If Feuil1.Range("G36") > 0 Then
If Feuil1.Range("M16") > 0 Then
With Feuil4 'Worksheets("BD")
NewLig = .Cells(.Rows.Count, 1).End(xlUp).Row + 1
.Cells(NewLig, 1) = Val(.Cells(NewLig - 1, 1)) + 1
.Cells(NewLig, 1).Resize(, 15).Borders.LineStyle = xlContinuous
i = 2
Set Plage = Feuil1.Range("G6,G8,G10,G14,G16,G19,G21,G23,G26,G28,G30,G34")
For Each c In Plage
.Cells(NewLig, i) = c
i = i + 1
Next c
Set Plage = Nothing
With .Cells(NewLig, 14)
.Formula = "=SUMPRODUCT(B2:M2,B" & NewLig & ":M" & NewLig & ")"
.Value = .Value
End With
.Cells(NewLig, 15) = IIf(Feuil1.Range("M16") = 1, "Chèque", "Espèce")
End With
MsgBox "Enregistrement effectué"
Effacer
Else
MsgBox "Choisir d'abord le type de paiement"
End If
Else
MsgBox "Aucune donnée à enregistrer"
End If
End Sub |
Partager