ComboBox - Populate Using .AddItem

vthokienj

Board Regular
Joined
Aug 1, 2011
Messages
103
I am trying to create then populate combobox with values from a collection. Seems simple enough but keeps it keeps crashing when I try to do anything like .clear or .additem. What am I doing wrong here? Thanks.

Code:
' create the box
Sheets("thesheet").Cells(1, 2).Select
       ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1",    
       Link:=False, DisplayAsIcon:=False).Select

Code:
' rename and populate
       With Selection
           comboName = "comboname"
           .name = comboName
           .AddItem "theitem"
       End With
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
try this. add ".Object"

Code:
Sheets("thesheet").Cells(1, 2).Select
       ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1").Select
 
       With Selection
                                  'comboname = "comboname" 
           .Name = "comboname"
           [U].Object.[/U]AddItem "theitem"
       End With
 
Upvote 0
SOLVED.

Original Poster, PM'd me and stated problem solved via posted solution.
 
Upvote 0

Forum statistics

Threads
1,215,477
Messages
6,125,037
Members
449,205
Latest member
Eggy66

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