Private Sub TAjouter_Click()
valide = True: TPersonne.BackColor = RGB(255, 255, 255): TDesignation.BackColor = RGB(255, 255, 255): TMontant.BackColor = RGB(255, 255, 255)
If Trim(TPersonne.Text) = "" Then valide = False: TPersonne.BackColor = RGB(255, 0, 0)
If Trim(TDesignation.Text) = "" Then valide = False: TDesignation.BackColor = RGB(255, 0, 0)
If TMontant.Text = "" Then TMontant.Text = 0
If CLng(TMontant) = 0 Then valide = False: TMontant.BackColor = RGB(255, 0, 0)
If valide Then Ajout
End Sub
Private Sub TMontant_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
adrPt = InStr(1, TMontant.Text, ".")
If KeyAscii = 46 Then
If Len(TMontant) = 0 Then
TMontant.Text = 0
ElseIf adrPt > 0 Then
KeyAscii = 0
End If
ElseIf Not IsNumeric(Chr(KeyAscii)) Then
KeyAscii = 0
ElseIf adrPt = Len(TMontant.Text) - 2 And adrPt > 0 Then
KeyAscii = 0
End If
End Sub
Function Ajout()
With Sheets("Brut").Range("A" & 2 ^ 20).End(xlUp).Offset(1)
.Value = Trim(TPersonne.Text)
.Offset(, 1) = ComboDT
.Offset(, 2) = "Débit"
.Offset(, 3) = Trim(TDesignation.Text)
.Offset(, 4) = CDbl(TMontant.Text)
End With
TPersonne.Text = "": TDesignation.Text = "": TMontant.Text = "": Me.Hide
TrierBrut
End Function
Private Sub UserForm_Activate()
TrierBrut
ComboDT = Now
End Sub