Dim f, bd, TabBD(), ColCombo()
Private Sub UserForm_Initialize()
Set f = Sheets("bd")
B_tout_Click
Set bd = f.Range("A2:Z" & f.[A65000].End(xlUp).Row) ' BD (A adapter)
TabBD = bd.Value
ColCombo = Array(5, 6, 7, 8, 9, 10, 11, 12, 13, 14) ' Colonnes comboBox (1 à 10 / A adapter)
For c = 1 To UBound(ColCombo) + 1: ListeCol c: Next c
For i = UBound(ColCombo) + 2 To 10: Me("combobox" & i).Visible = False: Me("label" & i).Visible = False: Next i
For i = 1 To UBound(ColCombo) + 1: Me("label" & i) = f.Cells(1, ColCombo(i - 1)): Next i
End Sub
Sub ListeCol(noCol)
Set MonDico = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(TabBD)
ok = True
For Cb = 0 To UBound(ColCombo)
ColBD = ColCombo(Cb)
If Cb + 1 <> noCol Then
If Not TabBD(i, ColBD) Like Me("comboBox" & Cb + 1) Then ok = False
End If
Next Cb
If ok Then
tmp = TabBD(i, ColCombo(noCol - 1))
MonDico(tmp) = ""
End If
Next i
MonDico("*") = ""
temp = MonDico.keys
Tri temp, LBound(temp), UBound(temp)
'If noCol = 9 Then For i = LBound(temp) To UBound(temp): temp(i) = Format(temp(i), "dd/mm/yyyy"): Next
Me("ComboBox" & noCol).List = temp
End Sub
Private Sub B_tout_Click()
For i = 1 To 10: Me("combobox" & i) = "*": Next i
On Error Resume Next
ActiveSheet.ShowAllData
End Sub