+ Reply to Thread
Results 1 to 8 of 8

VBA Userform - Multiple Comboboxes - Same Data

  1. #1
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    VBA Userform - Multiple Comboboxes - Same Data

    Good Morning!

    I have 20 comboxes that will need to have the exact same info in them... is there a way to make it so that Code is written one time for all of them?

    Or do i have to repeat over and over and over?
    Please Login or Register  to view this content.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,747

    Re: VBA Userform - Multiple Comboboxes - Same Data

    Are there other comboboxes besides the 20 that will all have the same data? If not you can do this:
    Please Login or Register  to view this content.
    If so, is there a naming convention to identify which ones belong to that group of 20? Then you can check CB.name instead of typename.

    Aside from the initialization, do you have other event handlers for the comboboxes?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: VBA Userform - Multiple Comboboxes - Same Data

    Hi Jeff!

    Thank you for your response. When you say Event Handlers do you mean like based on the response in the combo box something else happens? If so, then no.

    If not, then I am afraid that I am not following... can you explain?

    I have uploaded a sample of what I am working on here... the fields on the "Adult" and "Children" tabs are not yet programmed to put the info onto the main sheet yet.

    Ideally, I would like to make it so that instead of all of the Adults and Children options being there, that the people are asked to enter the number of adults and number of children, and they are just given input for each of those numbers.

    But I do not know if that is possible????
    Attached Files Attached Files

  4. #4
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: VBA Userform - Multiple Comboboxes - Same Data

    When I added the above code to the file, I get a "Complie error: Next without For"

  5. #5
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: VBA Userform - Multiple Comboboxes - Same Data

    Please Login or Register  to view this content.
    was just missing an end if
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,747

    Re: VBA Userform - Multiple Comboboxes - Same Data

    Quote Originally Posted by snuffnchess View Post
    When you say Event Handlers do you mean like based on the response in the combo box something else happens?
    I mean Subs that handle events like Click or Change. You do not use these for your comboboxes.

    Thanks to humdingaling, sorry I missed that End If. I put that code in and it seems to work, although the combo boxes also have a lot of blank rows at the end. You should redefine the name relationship to be

    =relat!$A$2:$A$25

  7. #7
    Spammer
    Join Date
    11-21-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    387

    Re: VBA Userform - Multiple Comboboxes - Same Data

    Thank you! This works perfectly!!!

  8. #8
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,747

    Re: VBA Userform - Multiple Comboboxes - Same Data

    You're welcome and thanks for the rep!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Add multiple items to multiple comboboxes - UserForm
    By stojko89 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-07-2017, 07:09 AM
  2. [SOLVED] Dynamic vendor contact userform with multiple comboboxes
    By yohanmcdonald in forum Excel General
    Replies: 1
    Last Post: 02-03-2015, 11:56 AM
  3. Multipying Multiple ComboBoxes on a Vba userform
    By smurfdjman in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-22-2013, 06:52 PM
  4. [SOLVED] Multiple dynamic Comboboxes in UserForm
    By joehjas in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-17-2012, 03:43 AM
  5. Adding information from multiple ComboBoxes in a UserForm (Looping?)
    By H0NKEN in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2012, 03:23 AM
  6. Data Validation for all TextBoxes and Comboboxes in Userform
    By singhabhijitkumar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-12-2010, 05:48 PM
  7. UserForm with Multiple ComboBoxes Populate
    By RobertCo in forum Excel General
    Replies: 2
    Last Post: 12-27-2006, 01:51 PM

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