View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default ComboBox on a Sheet

Sub abc()
Dim ole As OLEObject
Dim cbox As MSForms.Combobox
Dim cell as Range

Set ole = ActiveSheet.OLEObjects.Add( _
ClassType:="Forms.ComboBox.1", _
Link:=False, _
DisplayAsIcon:=False, _
Left:=67.5, _
Top:=275.25, _
Width:=63, _
Height:=40.5)
Set cbox = ole.Object
cbox.Name = "MyCombo"
for each cell in Range("sheet1!A1:A10")
ole.Object.AddItem cell.Value
Next
cbox.ListIndex = 3
Msg = "MyCombo has a value of " & _
ActiveSheet.OLEObjects("MyCombo").Object.Value
MsgBox Msg

End Sub

--
Regards,
Tom Ogilvy


wrote in message
oups.com...
This works great.

But is it possible to add the items to the ole object from within VBA
(using an assignment statement) rather than from a range.

Thanks!