Option Explicit
Dim Nop As Boolean
Private Sub UserForm_Initialize()
Dim t, i&
Nop = True
t = Sheets("Listes").ListObjects(1).ListColumns(1).Range
For i = 2 To UBound(t)
ComboChoixColFiltre.Text = t(i, 1)
If ComboChoixColFiltre.ListIndex = -1 Then ComboChoixColFiltre.AddItem t(i, 1)
Next i
ComboChoixColFiltre.Text = ""
ListBox1.Clear
End Sub
Private Sub ComboChoixColFiltre_click()
Dim t, ref, i&
Nop = True
t = Sheets("Listes").ListObjects(1).ListColumns(1).Range.Resize(, 2)
ComboBoxRech.Clear
If ComboChoixColFiltre.ListIndex = -1 Then Exit Sub
ref = ComboChoixColFiltre.Text
For i = 2 To UBound(t)
If ref = t(i, 1) Then
ComboBoxRech.Text = t(i, 2)
If ComboBoxRech.ListIndex = -1 Then ComboBoxRech.AddItem t(i, 2)
End If
Next i
ComboBoxRech.Text = ""
ListBox1.Clear
Nop = False
End Sub
Private Sub ComboBoxRech_Change()
Dim ref1, ref2, t, i&, j&
If Nop Then Exit Sub
ListBox1.Clear
ListBox1.ColumnCount = 5
ListBox1.ColumnWidths = "150;40;40;40"
If ComboBoxRech.ListIndex = -1 Then Exit Sub
ref1 = ComboChoixColFiltre.Text: ref2 = ComboBoxRech.Text
t = Sheets("Listes").ListObjects(1).ListColumns(1).Range.Resize(, 4)
For i = 2 To UBound(t)
If t(i, 1) = ref1 And t(i, 2) = ref2 Then
ListBox1.AddItem t(i, 1)
For j = 2 To 4: ListBox1.List(ListBox1.ListCount - 1, j - 1) = t(i, j): Next
End If
Next i
End Sub