Combo box list code....

jeet_singh23

New Member
Joined
Jul 19, 2011
Messages
3
Hi,
Please help me with the coding for the combo box. The combo box is in the userform. I want to add items in the drop down menu using VBA from range A6:A35 of a worksheet named "Summary", which may or may not be active since there are numerous sheets in one excel file.
One way I know of doing it is by going to the properties box and filling the rowsource as the range mentioned above. However, I dont want to do it that way. I am looking for some codeing only.
Can it be something like:
Sheets("Summary").Select
Combox1.Additem =(Range"A6:A35")
But the above code does not work.
Do let me know your thoughts.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
This code in your userform module would do it.


Private Sub UserForm_Initialize()
ComboBox1.List = Sheets("Summary").Range("A6:A35").Value
End Sub
 
Upvote 0
Hi,
Thanks for the quick reply.... I checked it but unfortunately is not working for me (perhaps something else might be interfering in my case).
Is there a way to post an attachment with thos post or send u email separatelty with the excel file?
Even in the private messages also there is no option for attaching file.... please do let me know...

Thanks....
 
Upvote 0
jeet

How is the code Tom posted not working?

No items appearing in combobox? Wrong items in combobox? Errors?
 
Upvote 0
You do not need to use AddItem and so on.

Like Tom said, use .List

Try:

Code:
Private Sub UserForm_Initialize()
   Combox1.List = Sheets("Summary").Range("A6:A35").Value
End Sub
 
Upvote 0
What, if anything, did you change in Tom's code?

Are you referring to the combobox correctly in the code?

If it's on a multipage then you might need to go through that to get to it. eg MultiPage1.Combobox1.List.
 
Upvote 0

Forum statistics

Threads
1,224,565
Messages
6,179,549
Members
452,927
Latest member
rows and columns

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