Private Sub Worksheet_Change(ByVal Target As Range)
If UserForms.Count Then CommandButton1_Click 'rouvre l'UserForm pour le mettre à jour
End Sub
Private Sub CommandButton1_Click()
Dim plage As Range, a, i&
Set plage = Range("B3:H" & Cells(Cells.Rows.Count, "B").End(xlUp).Row)
With UserForm1.ListBox1
.ColumnCount = plage.Columns.Count
.List = plage.Rows(IIf(plage.Row = 2, 1, 0)).Value
End With
With UserForm1.ListBox2
.ColumnCount = plage.Columns.Count
a = plage
For i = 1 To UBound(a): a(i, 5) = Format(a(i, 5), "hh:mm"): Next i
.List = a
If plage.Row = 2 Then .Clear 'si le tableau est vide
End With
UserForm1.ListBox3.AddItem [A2]
UserForm1.ListBox5.AddItem Sheets("STATS").[L1]
With Sheets("STATS").[H2:Q31]
.Parent.Worksheet_Activate 'exécute le tri
UserForm1.ListBox4.ColumnCount = .Columns.Count
UserForm1.ListBox4.ColumnWidths = Application.Rept((UserForm1.ListBox4.Width - 15) \ .Columns.Count & ";", .Columns.Count)
UserForm1.ListBox4.List = .Value
End With
UserForm1.Show 0 'ouverture en non modal
End Sub