Populating Combo Box on WorkBook Open

wtjessup

New Member
Joined
Jun 19, 2005
Messages
25
Is there any way to populate a combo box with a few items in a worksheet when the workbook is opened up? So far I can not get this to work with the WorkbookOpen() event.

Thanks in advance
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
What type of combobox is it?

Is it from the Forms or Controls Toolbox?

How have you tried to populate it?
 
Upvote 0
The combo box is from the controls toolbox and it is on the worksheet, not in a userform. I believe I can eventually figure out how to have them select one of the items and other actions be performed, but I just cant seem to get the list populated.
 
Upvote 0
What do you want to populate it with?

What code have you already tried?

If it's on a worksheet you should probably use the sheet's activate event to populate it.
 
Upvote 0
Using the Open event would be better, here is the general syntax for an example, modify for parent sheet name, combobox name, and the "few items" you want to populate the combobox with.

Private Sub Workbook_Open()
With Worksheets("Sheet1").OLEObjects("ComboBox1").Object
.Clear
.AddItem "Value 1"
.AddItem "Value 2"
.AddItem "Value 3"
.ListIndex = 0 'optional
End With
End Sub


Make sure the ListFillRange property of the combobox is empty.

Place the code in your workbook module and see if it accomplishes what you are after. To easily access your workbook module, find the little Excel workbook icon near the upper left corner of your workbook window, usually just to the left of the File menu option. Right click on that icon, left click on View Code, and paste the above procedure into the large white area that is the workbook module. Press Alt+Q to return to the worksheet.

After that, save the workbook, close it, and when you reopen it the values will be populated into the combobox as the code suggests.
 
Upvote 0
Thanks for those suggestions, I see where I wasnt putting the code in the right place (Worksheet instead of Workbook).
 
Upvote 0

Forum statistics

Threads
1,216,045
Messages
6,128,480
Members
449,455
Latest member
jesski

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