tags:

views:

14

answers:

1

I need to populate several comboboxes in an Excel sheet upon loading it.

I have the Workbook_Open() event set up on my ThisWorkbook code sheet in my VBA Editor.
Now that the code isn't in my Sheet1 code sheet in my VBA Editor, the following code doesn't work:

ComboBox.AddItem "hulkSMAASH!"

How can I reference this combobox from my ThisWorkbook code sheet in my VBA Editor?

+1  A: 

You can refer to the sheet's codename from anywhere, including in the ThisWorkbook module.

Sheet1.Combobox1.AddItem "hulkSMAASH!"

You can also access the OLEObjects collection

Me.Sheets("MySheet").OLEObjects("Combobox1").Object.AddItem "hulkSMAASH!"

Note that MySheet is the sheet's name and Sheet1 is the CodeName. You'll have to adjust for your particular names.

Dick Kusleika
I ended up using Worksheets("Sheet1").ComboBox1.AddItem "hulkSMAASH!"Thanks!
Soo