ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem Populating a ComboBox (https://www.excelbanter.com/excel-programming/419457-problem-populating-combobox.html)

Gary Kie

Problem Populating a ComboBox
 
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.Combo Box.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.

JLGWhiz

Problem Populating a ComboBox
 
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.

"Gary Kie" wrote:

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.Combo Box.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.


Jim Cone[_2_]

Problem Populating a ComboBox
 
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.Combo Box.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.Combo Box.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.

JLGWhiz

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

"Jim Cone" wrote:

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.Combo Box.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.Combo Box.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.



All times are GMT +1. The time now is 12:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com