+ Reply to Thread
Results 1 to 5 of 5

Fill multiple comboboxes with same values

Hybrid View

aman1234 Fill multiple comboboxes with... 05-13-2010, 05:04 AM
romperstomper Re: Fill multiple comboboxes... 05-13-2010, 06:11 AM
aman1234 Re: Fill multiple comboboxes... 05-13-2010, 06:38 AM
dougman824 Re: Fill multiple comboboxes... 06-12-2017, 06:00 PM
FDibbins Re: Fill multiple comboboxes... 06-13-2017, 01:55 AM
  1. #1
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Fill multiple comboboxes with same values

    Hi guys

    I hope anyone can help me in this. I have around 10 comboboxes and I want to fill them with the same values in userform_initialize event. I know we can do likt he following
    combobox1.additem "aaa"

    But as there are abount 15 values and around 10 comboboxes so its very time consuming to write so many statements to fill the values.

    Can anyone please give me a easy method to do this.

    Thanks

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,974

    Re: Fill multiple comboboxes with same values

    Put them in a range, then assign that to the list property:
    Dim varData
    varData = Sheets("data").Range("A1:A15").Value
    me.combobox1.List = vardata
    me.combobox2.list = vardata
    ' etc
    if your comboboxes have default names like combobox1 and combobox2, you could also use a loop to go through all 10.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Contributor
    Join Date
    02-20-2009
    Location
    bristol
    MS-Off Ver
    Excel 2003
    Posts
    882

    Re: Fill multiple comboboxes with same values

    Thanks a lot romper for your help. It worked perfectly fine. You are always helping. Thanks so much.

  4. #4
    Forum Contributor
    Join Date
    06-12-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    167

    Re: Fill multiple comboboxes with same values

    Hello,

    I am trying to do something similar with a userform. I have 30 comboboxes that all will have the same options to
    pick from so I would like to fill them with a loop. I also, if possible would like the range to be able to change if I have the list expand from user input. If both are not possible I can make it work without the dynamic list.
    Right now this is what I have:

    All of the comboboxes names start as "PMEmployeePT" and then a number.

    The error I get is: Could not set the list property. Invalid property array index (I also get similar things if I try rowsource)

    Sub PM_Systems_Loadcombos()

    Worksheets("Employees").Activate

    For i = 1 To fsrform.PMEmployees.Value
    Dim EmployeeTitle
    EmployeeTitle = Worksheets("Employees").Range("a3:a" & Rows.count).End(xlUp).Row
    fsrform.Controls("PMEmployeePT" & i).List = EmployeeTitle
    Next

    End Sub

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,048

    Re: Fill multiple comboboxes with same values

    Doug, welcome to the forum

    Unfortunately your post does not comply with Rule 2 of our Forum RULES. Do not post a question in the thread of another member -- start your own thread.

    If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread.

    Old threads are often only monitored by the original participants. New threads not only open you up to all possible participants again, they typically get faster response, too.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1