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
| Private Sub ValiderDettes_Click()
Dim DerniereLigne As Long
Dim Derligne As Integer
Dim LigneDebut As Long
Dim Ctrl As Control
Dim CtrI As Long
Dim r As Integer
With Worksheets("BD_DettesRéglements")
LigneDebut = 12
Derligne = .Range("C" & Cells.Rows.Count).End(xlUp).Row + 1
For Each Ctrl In AjoutDettes.Controls
r = Val(Ctrl.Tag)
If r > 0 Then
If Ctrl.Name = "Montant_TextBox" Then
.Cells(Derligne, r) = Val(Ctrl)
.Cells(Derligne, r).NumberFormat = "#,##0.00"
Else
.Cells(Derligne, r) = Ctrl
End If
End If
Next
'Tri par ordre alphabétique
Sheets("BD_DettesRéglements").Select
Range("B12:G" & Derligne).Sort Key1:=Range("C12"), Order1:=xlAscending, Header:=xlYes
'Avec la feuille consernée l'incrémentation numérique commence de la ligne 12 colonne B
DerniereLigne = .Cells(.Rows.Count, 3).End(xlUp).Row
For CtrI = LigneDebut To DerniereLigne
If .Cells(CtrI, 3) <> "" Then
.Cells(CtrI, 2) = WorksheetFunction.CountA(Range(.Cells(LigneDebut, 12), .Cells(CtrI, 7)))
Else
.Cells(CtrI, 2) = ""
End If
Next CtrI
'Le message
If MsgBox("La dette attribuée à (" & ComboBox1 & ") a été ajoutée avec succès voulez-vous enregistrer une autre dette ?", vbYesNo, "Confirmation") = vbYes Then
Montant_TextBox = ""
Me.ComboBox1.Clear
Me.ComboBox1.SetFocus
Else
Unload AjoutDettes
End If
End With
End Sub |
Partager