By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,594 Members | 2,097 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,594 IT Pros & Developers. It's quick & easy.

VBA - Combo Box

P: 8
I want a combobox in an userform which has a list of values already in the dropdown bar. Im quite new with vba and I'm stuck with this. I think I can use the rowsource property but this means I have to put some data into a worksheet, which I would prefer to avoid as I only want a userform

Thank you in advance for your help!
Nov 27 '06 #1
Share this Question
Share on Google+
3 Replies


Expert 5K+
P: 8,434
I want a combobox in an userform which has a list of values already in the dropdown bar. Im quite new with vba and I'm stuck with this. I think I can use the rowsource property but this means I have to put some data into a worksheet, which I would prefer to avoid as I only want a userform
Try looking into the .AddItem method, if you want to do it from VBA. If you want to just fill in a list at design time, you set the RowSourceType property to "Value List", and fill in the list in the RowSource property.
Nov 28 '06 #2

P: 8
Try looking into the .AddItem method, if you want to do it from VBA. If you want to just fill in a list at design time, you set the RowSourceType property to "Value List", and fill in the list in the RowSource property.

Thanks for the reply!

Still having trouble with this. VBA recognizes .rowsourcetype in the code, but how do i assign it to value list? I have tried the following
combobox1.rowsourcetype = value list
combobox1.rowsourcetype = "value list"
combobox1.rowsourcetype [=value list]

Nothing seems to work though.

The .additem method I gave a go too. I tried combobox1.additem ([Exampledata1, Example data2, Exampledata3])

Had no luck here either, could you possibly give me an example code to work with? Or tell me how to set the rowsource tpye to value list which will then let me enter values into the properties window of the userform.
Nov 28 '06 #3

Expert 5K+
P: 8,434
Still having trouble with this. VBA recognizes .rowsourcetype in the code, but how do i assign it to value list? I have tried the following
combobox1.rowsourcetype = value list
combobox1.rowsourcetype = "value list"
combobox1.rowsourcetype [=value list]
Nothing seems to work though.
I don't know, maybe it's case sensistive. The online help says to set it to "Value List".

The .additem method I gave a go too. I tried combobox1.additem ([Exampledata1, Example data2, Exampledata3])
For one thing, AddItem probably won't run until the RowSourceType has been set correctly. For another, you use it to add one string item at a time. So your example should be more like
Expand|Select|Wrap|Line Numbers
  1. combobox1.additem "Exampledata1"
  2. combobox1.additem "Example data2"
  3. combobox1.additem "Exampledata3"
  4.  
Had no luck here either, could you possibly give me an example code to work with? Or tell me how to set the rowsource tpye to value list which will then let me enter values into the properties window of the userform.
The simplest way would be to set Row Source Type in the properties window. You can find it under the Data or All tabs. (In Access 2003, that is. Don't know about other versions.)
Nov 28 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.