Private Sub CommandButton2_Click()
Dim DernL As Integer
[COLOR=Green][B]If TextBox1.Value = "" Then
MsgBox "vous avez oublier de rentrer le nom de la personne."
Exit Sub
End If[/B][/COLOR]
With Worksheets("commande") 'permet de détecter la deniere ligne du
DernL = Range("A65536").End(xlUp).Row 'tableau colonne A
[COLOR=Blue][B]If DernL > 45 Then 'A adapter si la première ligne n'est plus la 9.
MsgBox "le nombre de personne est limité à 37."
Exit Sub
End If[/B][/COLOR]
End With
ActiveSheet.Unprotect
Cells(DernL + 1, 1).Value = UCase(TextBox1.Value)
[B][COLOR=Red]Cells(DernL + 1, 2).Value = UCase(TextBox2.Value)[/COLOR][/B]
Range("A9").EntireRow.Copy
Range("A" & DernL + 1).EntireRow.PasteSpecial xlPasteFormats
Range("A9:A" & DernL + 1).EntireRow.Sort Key1:=ActiveCell, Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
ActiveSheet.Protect
TextBox1.Value = ""
End Sub