Welcome. Please help activate the userform combo box code to fetch data from several columns with the ability to search inside the text box I can now search with one item How can I activate 4 or 5 commobooks in the same way
VBA Code:
Dim f, bd()
Private Sub UserForm_Initialize()
Set f = Sheets("data")
f.Activate
bd = f.Range("a2:a" & [a65000].End(xlUp).Row).Value
Set d1 = CreateObject("scripting.dictionary")
For i = 1 To UBound(bd)
If bd(i, 1) <> "" Then d1(bd(i, 1)) = ""
Next i
a = d1.keys
Me.ComboBox1.List = a
Me.ComboBox1.SetFocus
End Sub
Private Sub ComboBox1_Change()
Set d1 = CreateObject("scripting.dictionary")
clé = UCase(Me.ComboBox1) & "*"
Dim Tbl()
n = 0: ncol = UBound(bd, 2)
For i = LBound(bd) To UBound(bd)
If UCase(bd(i, 1)) Like clé Then
n = n + 1: ReDim Preserve Tbl(1 To ncol, 1 To n)
For k = 1 To ncol: Tbl(k, n) = bd(i, k): Next
If bd(i, 1) <> "" Then d1(bd(i, 1)) = ""
End If
Next i
a = d1.keys
Me.ComboBox1.List = a
Me.ComboBox1.DropDown
Me.TextBox1.Value = Me.ComboBox1.Value
End Sub
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Set d1 = CreateObject("scripting.dictionary")
For i = 1 To UBound(bd)
If bd(i, 1) <> "" Then d1(bd(i, 1)) = ""
Next i
a = d1.keys
Me.ComboBox1.List = a
Me.ComboBox1.DropDown
Me.TextBox1.Value = Me.ComboBox1.Value
End Sub