Problem Populating a ComboBox

G

Gary Kie

When using the following code I get the error "Object doesn't support this
property or Method"

Public Sub Create_Supplier_List()
'

Set cb = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1",
Link:=False, _
DisplayAsIcon:=False, Left:=48.75, Top:=53.25, Width:=159,
Height:= _
18.75)

Sheets(2).cb.ListFillRange = Sheets(2).Range("C2:C6")

End Sub

Please can you assist me with my problem.
 
J

JLGWhiz

OLEObjects combobox does not have a ListFillRange property. You will have to
populate the coombobox using the AddItem method. Or you can use the control
from the Control Toolbox which does have a ListFillRangeProperty.
 
J

Jim Cone

On the other hand, this worked for me...
(assumes "Sheet2" is the name of the sheet containing the data)
'--
Public Sub Create_Supplier_List_R1()
Dim cb As OLEObject

Set cb = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1", _
Link:=False, DisplayAsIcon:=False, Left:=48.75, Top:=53.25, _
Width:=159, Height:=18.75)
cb.ListFillRange = "Sheet2!C2:C6"
End Sub
--
Jim Cone
Portland, Oregon USA



"Gary Kie"
wrote in message
When using the following code I get the error "Object doesn't support this
property or Method"

Public Sub Create_Supplier_List()
Set cb = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ComboBox.1",
Link:=False, _
DisplayAsIcon:=False, Left:=48.75, Top:=53.25, Width:=159,
Height:=18.75)
Sheets(2).cb.ListFillRange = Sheets(2).Range("C2:C6")
End Sub

Please can you assist me with my problem.
 
J

JLGWhiz

I stand corrected. I always create my forms manually, so I have more to
learn in doing them by code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top