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
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.
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
Summary: Hi I was wondering if anyone knows how to collect data from excel, and code it in VBA so it transfers it into a combo box in VBA, because i'm doing a project and i need the names of 4 teams that a...
Summary: Iam using ADO & there r 10 Roll numbers in Roll Number Field. I want to populate combo box at form load event & see all 10 roll numbers in the combo box. I use the code in form load event Combo1.Ad...
Summary: G'day , i am trying to workout how to change the contence of a combo box in referance to what was in the previous box IE if someone selects dell from 1 combo box the next box will have the model of de...