Dim f, a()
Private Sub UserForm_Initialize()
Set f = Sheets("bd")
a = f.Range("b2:H" & f.[B65000].End(xlUp).Row).Value
Dim collect As New Collection
Dim Tbl(1 To 3)
On Error Resume Next
For i = 1 To UBound(a)
Tbl(1) = a(i, 1)
Tbl(2) = a(i, 2)
Tbl(3) = a(i, 3)
collect.Add Tbl, Key:=CStr(a(i, 1))
Next i
On Error GoTo 0
Dim b(): ReDim b(1 To 3, 1 To collect.Count)
For i = 1 To collect.Count
b(1, i) = collect(i)(1)
b(2, i) = collect(i)(2)
b(3, i) = collect(i)(3)
Next i
Me.ComboBox1.List = Application.Transpose(b)
End Sub
Private Sub ComboBox1_Click()
Me.TextBox1 = Me.ComboBox1.Column(1) & " " & Me.ComboBox1.Column(2)
Me.ListBox1.Clear
j = 0
For i = LBound(a) To UBound(a)
If Val(Me.ComboBox1) = a(i, 1) Then
Me.ListBox1.AddItem a(i, 4)
On Error Resume Next
Me.ListBox1.List(j, 1) = a(i, 5)
Me.ListBox1.List(j, 2) = a(i, 6)
Me.ListBox1.List(j, 3) = a(i, 7)
On Error GoTo 0
j = j + 1
End If
Next i
End Sub
Private Sub ListBox1_Click()
Me.Remarques = Me.ListBox1.Column(3)
Me.Validité = Me.ListBox1.Column(1)
Me.Restant = Me.ListBox1.Column(2)
End Sub