View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ker_01 ker_01 is offline
external usenet poster
 
Posts: 395
Default Userform combobox: best match on partially typed content?

I've added a combobox to my userform. Exact match is required.

When I begin typing, if there is one or more exact match, it will pre-fill
the combobox text with the first possible exact match. Once I am close to the
target selection, I can just click the drop-down arrow and select my target
item.

However, if I mis-type or am a letter off of a valid selection, when I click
the down arrow, instead of being at the last acceptable match, it puts me
back at the top of the list.

In this particular case, the combobox may have several thousand entries, and
the spelling of some items are not intuitive. Is there any way to force the
combobox to stay at the last found match? For example, to programmatically
capture the last valid match (which the combobox has somewhere, because it is
pre-populating it), and then use that value to force the combobox location
even if the currently typed text is not a valid match for anything on the
list?

For example, if the desired match is "G425 p2 Electric" and another item is
"G425 e Electric" then I get a match up through typing "G425 ". If I stop
there and hit the combobox dropdown, I'll see my match in the list near the
exact match I'm on. However, if I type "G425 p El" because I didn't know
there was a "2" on this item, it plops me back at the very beginning of the
list, instead of still being in the part of the list where I could easily
find the target item.

So, I'm looking for how to capture the valid match item ID (each time a
match is made), and how to force the combobox to go to that location when the
dropdown is selected, even if the current text is not an exact match.

Thanks!
Keith