Drop down box

Jess84

New Member
Joined
Jun 20, 2017
Messages
6
Office Version
  1. 365
Platform
  1. Windows
I'll try and explain this the best I can

I'm using a spreadsheet at work where I have created a drop down list of suburbs.
It's not really what I want
I want to be able to start typing a suburb and the name comes up and then just press enter when it's the correct suburb
Is there a name for this option so i can google the instructions

Thank you :):)
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
By dropdown do you mean a combobox?
Here’s an example of a combobox that can search as you type:


Code:
[FONT=lucida console][COLOR=Royalblue]Private[/COLOR] [COLOR=Royalblue]Sub[/COLOR] ComboBox1_Change()

[COLOR=Royalblue]Dim[/COLOR] d [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Object[/COLOR], vList1, i [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR]
vList1 = Sheets([COLOR=brown]"deList"[/COLOR]).Range([COLOR=brown]"A2"[/COLOR], Sheets([COLOR=brown]"deList"[/COLOR]).Cells(Rows.Count, [COLOR=brown]"A"[/COLOR]).[COLOR=Royalblue]End[/COLOR](xlUp)).Value
   
[COLOR=Royalblue]With[/COLOR] ComboBox1
[COLOR=Royalblue]If[/COLOR] .Value <> [COLOR=brown]""[/COLOR] [COLOR=Royalblue]And[/COLOR] IsError(Application.Match(.Value, vList1, [COLOR=crimson]0[/COLOR])) [COLOR=Royalblue]Then[/COLOR]
    [COLOR=Royalblue]Set[/COLOR] d = CreateObject([COLOR=brown]"scripting.dictionary"[/COLOR])
    [COLOR=Royalblue]For[/COLOR] i = LBound(vList1) [COLOR=Royalblue]To[/COLOR] UBound(vList1)
        [COLOR=Royalblue]If[/COLOR] LCase(vList1(i, [COLOR=crimson]1[/COLOR])) [COLOR=Royalblue]Like[/COLOR] [COLOR=brown]"*"[/COLOR] & Replace(LCase(.Value), [COLOR=brown]" "[/COLOR], [COLOR=brown]"*"[/COLOR]) & [COLOR=brown]"*"[/COLOR] [COLOR=Royalblue]Then[/COLOR]
          d(vList1(i, [COLOR=crimson]1[/COLOR])) = [COLOR=crimson]1[/COLOR]
        [COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]If[/COLOR]
    [COLOR=Royalblue]Next[/COLOR]
       .List = d.keys
       .DropDown
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]If[/COLOR]
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]With[/COLOR]
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR]


[COLOR=Royalblue]Private[/COLOR] [COLOR=Royalblue]Sub[/COLOR] ComboBox1_GotFocus()
ComboBox1.MatchEntry = fmMatchEntryNone
ComboBox1.Value = [COLOR=brown]""[/COLOR]
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR]

[COLOR=Royalblue]Private[/COLOR] [COLOR=Royalblue]Sub[/COLOR] ComboBox1_DropButt*******()
[COLOR=Royalblue]Dim[/COLOR] vList, d [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Object[/COLOR], i [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR]
[COLOR=Royalblue]If[/COLOR] ComboBox1.Value = vbNullString [COLOR=Royalblue]Then[/COLOR]
vList = Sheets([COLOR=brown]"deList"[/COLOR]).Range([COLOR=brown]"A2"[/COLOR], Sheets([COLOR=brown]"deList"[/COLOR]).Cells(Rows.Count, [COLOR=brown]"A"[/COLOR]).[COLOR=Royalblue]End[/COLOR](xlUp)).Value
    [COLOR=Royalblue]Set[/COLOR] d = CreateObject([COLOR=brown]"scripting.dictionary"[/COLOR])
    [COLOR=Royalblue]For[/COLOR] i = LBound(vList) [COLOR=Royalblue]To[/COLOR] UBound(vList)
          d(vList(i, [COLOR=crimson]1[/COLOR])) = [COLOR=crimson]1[/COLOR]
    [COLOR=Royalblue]Next[/COLOR]
       ComboBox1.List = d.keys
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]If[/COLOR]
[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR][/FONT]

The sample workbook:

https://www.dropbox.com/s/262bsb6w724o0ye/deCombobox - search as you type - example.xlsm?dl=0
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
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