ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill Combo Box (https://www.excelbanter.com/excel-programming/401484-fill-combo-box.html)

krsone21121983

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

[email protected]

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


All times are GMT +1. The time now is 04:24 AM.

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