Private Sub CommandButton2_Click()
Dim LastLine As Long
If Not IsDate(Me.TextBox5) Then
MsgBox 'Vous devez indiquer une date valide'
Exit Sub
End If
If TextBox5 = Empty Then
UserForm4.Show
ElseIf TextBox6 = Empty Then
UserForm5.Show
ElseIf TextBox7 = Empty Then
UserForm6.Show
Else
With Sheets('Feuil1')
.Unprotect
LastLine = .Range('A65536').End(xlUp).Row + 1
With .Range('A' & LastLine)
.Value = CDate(TextBox5.Value)
.NumberFormat = 'dd/mm/yyyy'
End With
.Range('B' & LastLine).Value = Month(TextBox5.Value)
.Range('C' & LastLine).Value = Day(TextBox5.Value)
.Range('D' & LastLine).Value = TextBox6.Value
.Range('E' & LastLine).Value = TextBox7.Value
End With
TextBox5 = ''
TextBox6 = ''
TextBox7 = ''
MsgBox ('votre relevé a été pris en compte')
End If
Dim L As Integer
With Sheets('feuil1')
L = .Range('a65536').End(xlUp).Row
.Range('A1:E' & L).Sort Key1:=Range('A1'), Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub