List Box and Quick selecton of item in drop down

  • Thread starter Thread starter Katie412
  • Start date Start date
K

Katie412

This may be a real simple issue, but I am, unforutnately, not that savy
with VBA and the help isn't helping on this one.

I have a list box whose drop down menu contains a set of states.
for example:

Arizona
California
Utah
Washington
Wisconsin

Currently, if the user wishes to select Wisconsin they must scroll to
the bottom of the list. In other applications I have seen on the web,
the user could type "W" and the drop down menu would automatically
access Washington, the 1st state with a W. Is anyone familiar with a
function that can be built into a listbox?

Thanks,
Katie
 
Katie412 > said:
This may be a real simple issue, but I am, unforutnately, not that savy
with VBA and the help isn't helping on this one.

I have a list box whose drop down menu contains a set of states.
for example:

Arizona
California
Utah
Washington
Wisconsin

Currently, if the user wishes to select Wisconsin they must scroll to
the bottom of the list. In other applications I have seen on the web,
the user could type "W" and the drop down menu would automatically
access Washington, the 1st state with a W. Is anyone familiar with a
function that can be built into a listbox?

Thanks,
Katie


Hi Katie !

Quite frankly, that's exactly how a listbox is supposed to work in VBA. Have
verified it with short example that I set up on my machine. I added a
ListBox to a UserForm, and added entries to that list like below (not very
elegant, but it works ...) :

Me.ListBox1.AddItem("Arizona")
Me.ListBox1.AddItem("California")
etc.etc.

And when you get the UserForm into "run" mode, click on the listbox and
press the "W" key, the selection *does* jump to Washington. In fact, this
works for both, ListBox and ComboBox controls - given the case that the
control *does* have the focus at the time you press the respective key.

cheers,
Markus
 
Take a look at the ListBox's MatchEntry property e.g. set it to
fmMatchEntryFirstLetter.
 
Back
Top