Option Explicit
Private Sub UserForm_Initialize()
Dim tablo, dico, i&
With Worksheets("Liste")
If .AutoFilterMode Then .Cells.AutoFilter
tablo = .Range("L3", .Range("L" & .Rows.Count).End(xlUp)).Value
Set dico = CreateObject("scripting.dictionary")
For i = 1 To UBound(tablo): dico(tablo(i, 1)) = "": Next i
ComboBox1.List = dico.keys
End With
End Sub
Private Sub CommandButton1_Click()
Dim n, xrg As Range
Application.ScreenUpdating = False
With Worksheets("Liste")
If .AutoFilterMode Then .Cells.AutoFilter
n = .Range("L" & Rows.Count).End(xlUp).Row
On Error Resume Next
.Range("a2:o" & n).AutoFilter Field:=12, Criteria1:=ComboBox1
Set xrg = .Range("a2:o" & n).SpecialCells(xlCellTypeVisible)
With Worksheets("Bon-Chauffeur")
.Range("a2:o" & 21).EntireRow.ClearContents
xrg.Copy .Range("a2")
MsgBox "La copie de " & .[a2].CurrentRegion.Rows.Count - 1 & _
" ligne(s) de donnée est terminée.", vbInformation
End With
If .AutoFilterMode Then .Cells.AutoFilter
End With
Application.ScreenUpdating = True
End Sub