Hello,
i have inserted a ComboBox called "ComboBox1" into an Excel Sheet. Now
I would like to fill this using vba.
unfortunately ComboBox1.additem "test" does not work. this only seems
to work when i insert a combobox into a user form.
how do i fill the combo box that is placed directly into the excel
sheet using vba?
thanks for your help
Mike Fogleman - 21 Nov 2007 15:04 GMT
In a standard code module, this worked for me using a combobox from the
Control Toolbox:
Worksheets("Sheet1").ComboBox1.AddItem "Hello"
Mike F
> Hello,
>
[quoted text clipped - 8 lines]
>
> thanks for your help
SAPkannan@gmail.com - 25 Nov 2007 17:01 GMT
Hi,
If you want to fill single word, try this code
With Sheet1.ComboBox1
.Value = "Test"
End With
If you want to fill a range of list then try the following.
Dim n As Integer
n = Cells(Rows.Count, "A").End(xlUp).Row
With Sheet1.ComboBox1
.AutoSize = False
.AutoTab = False
.List = Worksheets("Sheet1").Range("A1:A" & n).Value 'Range of
List containing in the Column A:A
End With
Regards,
Kannan