Option Compare Text
Dim f, Rng, ColVisu(), TBlBD()
Private Sub UserForm_Initialize()
Me.ComboBox2.Clear
Me.ListBox1.Clear
Set f = Sheets("ListeDesDevis") ' Adapter
nomTableau = "ListeDevis1"
TBlBD = Range(nomTableau).Value
Set Rng = f.Range("A2:G" & f.Range("A" & Rows.Count).End(xlUp).Row) ' Adapter
ColVisu = Array(1, 2, 4, 6) ' Adapter
LargeurCol = Array(150, 150, 150, 100) ' Adapter
Me.ListBox1.ColumnCount = UBound(ColVisu) + 1
Me.ListBox1.ColumnWidths = Join(LargeurCol, ";")
Me.ListBox1.List = Application.Index(Rng, Evaluate("Row(2:" & Rng.Rows.Count & ")"), ColVisu)
'--- ComboBox
Set d = CreateObject("scripting.dictionary")
'd("*") = ""
For i = 2 To UBound(TBlBD, 1)
If Not d.exists(TBlBD(i, 24)) Then
d.Add TBlBD(i, 24), ""
End If
Next i
Me.ComboBox2.List = d.keys
End Sub
Private Sub ComboBox2_click()
Me.ListBox1.Clear
ColRecherche = 24
clé = Me.ComboBox2: n = 0
Dim Tbl()
For i = 1 To UBound(TBlBD)
If TBlBD(i, ColRecherche) Like clé Then
Me.ListBox1.AddItem TBlBD(i, 1)
Me.ListBox1.List(ListBox1.ListCount - 1, 1) = TBlBD(i, 2)
Me.ListBox1.List(ListBox1.ListCount - 1, 2) = TBlBD(i, 4)
Me.ListBox1.List(ListBox1.ListCount - 1, 3) = TBlBD(i, 6)
End If
Next i
End Sub