PDA

View Full Version : Solved: Populating Combo Box With Values VBA



Bopo2
11-01-2009, 07:30 AM
Hey all

Okay well I have a UserForm, and I have a combo box control which I want to be populate with many customer ID's. The problem I have at the moment is that obviously the worksheet will have new records all the time, therefore I can't just say a static range:

Me.cboid.RowSource = "A2:A28"

As there might be 10 new rows, also the above only works providing the customer worksheet is actually selected, therefore I'm trying to find the syntax to address a specific worksheet as well, help appreciated.

Bopo2
11-01-2009, 07:34 AM
Figured out a solution.

n = Cells(Rows.Count, "A").End(xlUp).Row
For Each r In Worksheets("data").Range("A9:A" & n)
i = i + 1
Next

lucas
11-01-2009, 10:41 AM
You can also use a named range in the rowsource of the combo box and it won't matter what sheet it is on.