combo box

K

Kim

How can set the ListFillRange of a combo box via code instead of using the
properties form?

Thanks,

Kim
 
D

Dave Peterson

Is it a combobox from the control toolbox toolbar placed on a worksheet?

if yes, then here's one way:

Option Explicit
Sub testme01()

Dim OLEobj As OLEObject

With ActiveSheet.Range("a12:c12")
Set OLEobj = .Parent.OLEObjects.Add(ClassType:="Forms.ComboBox.1", _
Link:=False, DisplayAsIcon:=False, _
Left:=.Left, Top:=.Top, Width:=.Width, Height:=.Height)

With OLEobj
.ListFillRange _
= Worksheets("sheet2").Range("a1:a10").Address(external:=True)
.LinkedCell _
= Worksheets("sheet2").Range("b1").Address(external:=True)
End With
End With

End Sub
 
Top