Fill Combo Box

K

krsone21121983

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
 
M

Mike Fogleman

In a standard code module, this worked for me using a combobox from the
Control Toolbox:

Worksheets("Sheet1").ComboBox1.AddItem "Hello"

Mike F
 
S

SAPkannan

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
 

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