Import specific column data into combobox

sofas

Active Member
Joined
Sep 11, 2022
Messages
468
Office Version
  1. 2019
Platform
  1. Windows
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


10.PNG


11.PNG
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Hello I am still looking for a solution to my problem I found this code but when I try to add the second element an error message appears


VBA Code:
Dim a()
Private Sub UserForm_Initialize()
  a = Application.Transpose([liste])
  Me.ComboBox1.List = a
 
 
  b = Application.Transpose([liste2])
  Me.ComboBox2.List = b
End Sub
Private Sub ComboBox1_Change()
  Me.ComboBox1.List = Filter(a, Me.ComboBox1.Text, True, vbTextCompare)
   Me.ComboBox1.DropDown
 
End Sub
Private Sub ComboBox2_Change()
  Me.ComboBox2.List = Filter(b, Me.ComboBox2.Text, True, vbTextCompare)
   Me.ComboBox2.DropDown
 
 
End Sub

100.PNG


https://www.mediafire.com/file/mq57itnq8xekoun/ListBoxMultiColIntuitifCombobox.xlsm/file
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top