PC Review


Reply
Thread Tools Rate Thread

Code for combobox

 
 
REM
Guest
Posts: n/a
 
      23rd Aug 2009
I am struggling to write code that allows the user to progressively
select a value from a list. For example from a long list the user
could type R to show all the items starting with R, then type o, to
reduce the list to all items starting with Ro etc.

Secondly if the user types a term that is not on the list, it should
be added to the list for future selection.

As I see it this is the primary purpose of a combo-box but I cant find
the above code. Any help will be appreciated.
Thanks,
Rod
 
Reply With Quote
 
 
 
 
Matthew Herbert
Guest
Posts: n/a
 
      24th Aug 2009
REM,

How do you plan on loading your ComboBox?

My initial thoughts are that you can create the combo box list in a
worksheet (which you could make hidden or very hidden) to store the values
for the combo box. It's likely that you can then use the ListIndex property
to test whether the item is in the combo box or not. (A value of -1 means
that the item is not in the list). If the item isn't in the list, you can
append it to your combo box list on the aforementioned worksheet.

If you choose to add the items in the combo box via a worksheet, then you
can utilize the RowSource property to load the items quite quickly;
otherwise, you'll need to use the AddItem method. I hope this is enough to
get you started.

Best,

Matthew Herbert

"REM" wrote:

> I am struggling to write code that allows the user to progressively
> select a value from a list. For example from a long list the user
> could type R to show all the items starting with R, then type o, to
> reduce the list to all items starting with Ro etc.
>
> Secondly if the user types a term that is not on the list, it should
> be added to the list for future selection.
>
> As I see it this is the primary purpose of a combo-box but I cant find
> the above code. Any help will be appreciated.
> Thanks,
> Rod
>

 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      24th Aug 2009
you could do this with a userform. I like to use 2 list boxes and an edit box
one list box should hold all the data and should have visible = false
The text box is the filter. each time a character is typed to the exit box,
the listbox is filtered and results placed into the 2nd listbox. Works well
and can easily be adapted for adding values if they don't exist.

If this is atill an issue, I can let you have a demo spreadsheet.



"REM" wrote:

> I am struggling to write code that allows the user to progressively
> select a value from a list. For example from a long list the user
> could type R to show all the items starting with R, then type o, to
> reduce the list to all items starting with Ro etc.
>
> Secondly if the user types a term that is not on the list, it should
> be added to the list for future selection.
>
> As I see it this is the primary purpose of a combo-box but I cant find
> the above code. Any help will be appreciated.
> Thanks,
> Rod
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
combobox code swain.s@blueyonder.co uk Microsoft Excel Misc 0 20th Dec 2009 08:28 AM
Combobox Code Andy Microsoft Access Form Coding 2 16th Jan 2008 03:52 PM
Code for ComboBox =?Utf-8?B?Um9i?= Microsoft Excel Programming 8 10th Sep 2006 07:28 PM
HowTo? shift focus in VBA IDE between Object combobox, procedure combobox, and Code window Malcolm Cook Microsoft Access 0 11th Oct 2005 03:42 PM
multiColumn ComboBox - found the C++ code, need C# code Keith Smith Microsoft C# .NET 0 9th Feb 2005 11:15 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:17 PM.