Option Explicit
Dim ShBd As Worksheet, Rng As Range, BD, d As Object, temp, temp1, Coll_Factures
Private Sub UserForm_Initialize()
Dim i As Integer, n, d
Set ShBd = ThisWorkbook.Sheets("Comptes")
Set Rng = ShBd.Range("A6:L" & ShBd.[A65000].End(xlUp).Row)
BD = Rng.Value
Me.ComboBox1.ColumnCount = 2
Me.ComboBox1.ColumnWidths = "20;50"
Set d = CreateObject("scripting.dictionary")
n = 0
For i = LBound(BD) To UBound(BD)
If Not d.exists(BD(i, 2)) Then
d(BD(i, 2)) = ""
Me.ComboBox1.AddItem BD(i, 2)
Me.ComboBox1.List(n, 1) = BD(i, 10)
n = n + 1
End If
Next i
End Sub
Private Sub ComboBox1_click()
If Me.ComboBox1.ListIndex = -1 Then Exit Sub
Me.TextBox1.Value = Me.ComboBox1.Column(1)
End Sub