using dropdown(combobox) instead of data validation to autocomplete items

abdo meghari

Well-known Member
Joined
Aug 3, 2021
Messages
651
Office Version
  1. 2019
Hi Guys,
I search for using three combo boxes instead of data validation
combobox1 will be in column B,combobox2 will be in column C,combobox3 will be in column D, and should start from row21
when I select combobox1 should populate item in combobox2 based on combobox1 , when select combobox2 then should populate item in combobox 3 based on combobox1,2
for instance :
I have data like this
column B,C,D in BRAND sheet from row2
B C D
BS 1200R20 G580 JAP
BS 1200R20 G580 THI
BS 1200R20 R187 THI
BS 1400r20 VS JAP
combobox1,2,3 are existed in INVOICE sheet from row 21
when select combobox1 =BS 1200R20, then populate in combobox2 =G580 ,R187 , and when select combobox2=G580 then will populate JAP,THI in combobox3
so I don't want any duplicates items in comboboxes 1,2,3 when select specific item as in BS 1200R20 and when write ITEM for instance in combobox1 BS 1200R20 should autocomplete and filter list contains based on written .
I'm talking about OLEObjects(combobox), not on userform .
thanks in advance .
 
Try this example:
I haven't implemented the search feature yet. See if it works for you then I'll finish the code.
The workbook:
 
Upvote 1

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Ok, this version already has the searchable feature, you can type multiple keyword separated by a space.

You need to amend the code in this part:

In module1:
VBA Code:
'range where you want to use the combobox [in the sample: "D5:F8" in "sheet1", the green area)
Public Const xCell As String = "D5:F8"   '###

In Userform1:
VBA Code:
Private Sub UserForm_Initialize()
Dim i As Long
    '### DATA SOURCE to populate combobox, in this example data source is in Sheets("deList"), col A:C, start at A2
    With Sheets("deList")
        vList = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp)).Resize(, 3)
    End With

data entry via 3 dependent combobox.jpg


The work book:
 
Upvote 1
Solution
You're welcome, glad to help & thanks for the feedback.:)
 
Upvote 0
@abdo meghari
Sorry, the code is bit flawed regarding the 3rd combobox.
You need to add this code in the Userform1 code module:
VBA Code:
Private Sub ComboBox3_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)

nFlag = False
With Me.ComboBox3
    Select Case KeyCode
       
        Case vbKeyDown, vbKeyUp
             nFlag = True 'don't change the list when combobox1 value is changed by DOWN ARROW or UP ARROW key
         
    End Select
 
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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