Consulting

Results 1 to 3 of 3

Thread: Solved: Populating Combo Box With Values VBA

  1. #1

    Solved: Populating Combo Box With Values VBA

    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:

    [VBA]Me.cboid.RowSource = "A2:A28"[/VBA]

    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.

  2. #2
    Figured out a solution.

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

  3. #3
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    You can also use a named range in the rowsource of the combo box and it won't matter what sheet it is on.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •