Private Sub CommandButton2_Click()
If ActiveWorkbook.Name <> ThisWorkbook.Name Then ThisWorkbook.Activate
For x = 2 To 14
TextBox1.Caption = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox9.Value = ""
TextBox10.Value = ""
TextBox11.Value = ""
TextBox12.Value = ""
TextBox13.Value = ""
TextBox14.Value = ""
With Me.ListBox1
Cells(.ListIndex + 2, x) = Me.Controls("TextBox" & x).Value 'On écrit dans chaque colonne les valeurs des différents controls
Cells(.ListIndex + 2, 1) = Me.TextBox1.Caption
End With
Next x
Sheets("Année 2023").ListObjects("Tableau1").Sort.SortFields _
.Clear
Sheets("Année 2023").ListObjects("Tableau1").Sort.SortFields _
.Add2 Key:=Range("Tableau1[[#All],[Numéro]]"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Année 2023").ListObjects("Tableau1").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Unload USF_EditAlerte
USF_EditAlerte.Show
ThisWorkbook.Save
End Sub