Computing.Net > Forums > Programming > Populating a combo box vba

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Populating a combo box vba

Reply to Message Icon

Name: Jayy
Date: February 19, 2007 at 04:16:53 Pacific
OS: xp
CPU/Ram: na
Product: na
Comment:

I need to populate a combo box with a list of information stored on a sheet.

The information can be edited tho and will need to be done using a loop and "do without" as there could be spaces in the infomation.

Thanks for any help.



Sponsored Link
Ads by Google

Response Number 1
Name: jon_k
Date: February 20, 2007 at 05:18:04 Pacific
Reply:

This is what worked for me when I had to do a similar task: please note I used additem as I only had one bit of info per line to add.

The code adds all the items to the combobox, then selects the column your cursor is in.

This is possibly horribly inefficient, as well, but I figure it might help (incidentally this is on the initialize event of the userform):

Private Sub UserForm_Initialize()
ComboBox1.SetFocus
For datacol = 4 To 254
If Len(Sheet1.Cells(4, datacol).Value) > 0 Then
ComboBox1.AddItem Sheet1.Cells(4, datacol).Value
End If
Next datacol
ComboBox1.Value = Sheet1.Cells(4, Selection.Column).Value
End Sub


0

Response Number 2
Name: Jayy
Date: February 20, 2007 at 05:46:57 Pacific
Reply:

Thanks alot Jon <3 ♥


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Populating a combo box vba

Combo Boxes in VBA www.computing.net/answers/programming/combo-boxes-in-vba/9015.html

Populating Combo Box www.computing.net/answers/programming/populating-combo-box/9937.html

MS-Access VBA Combo box www.computing.net/answers/programming/msaccess-vba-combo-box/5587.html