Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Fill Combo Box

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
krsone21121983 - 21 Nov 2007 12:59 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.