View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Dan Gesshel Dan Gesshel is offline
external usenet poster
 
Posts: 20
Default Adding Items To Active X ComboBox on Sheet

Hmm... well, I'm trying different variations of this and I keep coming up
with a Permission Denied error (which I don't recall seeing before.) Here's
what I have:

Dim MyCollection As New Collection

For Each Item In MyCollection
ActiveSheet.OLEObjects("MyComboBox").Object.AddIte m Item
Next Item

If I change this and add:

ActiveSheet.OLEObjects("MyComboBox").Object.AddIte m Item.Value
(adding .Value)

I receive an Object Required error. Normally I can muck my way through
these, but this time I'm having some problems getting it.

Any additional help Tom would be great.

Thanks

Dan


"Tom Ogilvy" wrote in message
...
for each item in Mylist
Activesheet.Combobox1.AddItem item
Next

or

assume the OleObject name of the combobox is MyCombobox (in xl2000 and
later, the name of the combobox and the oleobject name should be the same.

for each item in List
Activesheet.OleObjects("MyComboBox").Object.AddIte m Item
Next


Here is a tested Example:

Sub AddStuff()
Dim rng as Range
Dim cell as Range
With Worksheets("Sheet8")

Set rng = .Range(.Cells(1, 1), _
.Cells(1, 1).End(xlDown))
For Each cell In rng
.OLEObjects("MyComboBox").Object _
.AddItem cell.Value
Next
End With
End Sub

--
Regards,
Tom Ogilvy


Dan Gesshel wrote in message
...
Hello.

I am trying to add a list to an ActiveX ComboBox on the sheet itself. I

am
able to do this using a Userform:

For Each Item In MyList
MyForm.MyComboBox.AddItem Item
Next Item

This works great... for Userforms. I'm having trouble with the correct
syntax for a ComboBox residing on the sheet, and not in a Userform. Can
anyone out there help?

Thanks.

Dan