+ Reply to Thread
Results 1 to 5 of 5

Using Multiple Combo Box Values to populate a cell (Excluding blank combo boxes)

  1. #1
    Registered User
    Join Date
    02-11-2016
    Location
    Wisconsin
    MS-Off Ver
    07-360
    Posts
    53

    Using Multiple Combo Box Values to populate a cell (Excluding blank combo boxes)

    Hi, I am using Excel '07 and have a user form which allows the user to list people present divided into 2 groups. Currently I have 10 combo boxes for staff, as well as an additional 10 combo boxes for others. Each grouping of combo boxes is populated by using a dynamic range referencing each category (probably TMI but you never know). The goal is to have all of the staff listed in one cell on the worksheet (cells(3, "J")) and all of the other people in (cells(3,"K")). I would like each person to be separated by a comma and the last to have an Ampersand before it [Staff1, Staff2, .... Staff9, & Staff10]. Getting this to work with all 10 combo boxes is not an issue, but I would like to have it work without unnecessary punctuation if say only 4 list boxes are used. Results should appear as [Staff1, Staff2, Staff3, & Staff4], but currently are [Staff1, Staff2, Staff3, Staff4, , , , , , &].

    I have tried to get this with 2 different (staff & other) IF and ElseIF statements which I believe to be the issue as it seems in both instances, it is accepting the first IF.

    ComboBox Properties:
    All except the first (eg. CB_Staff1) have .visible = False as default. If the Previous ComboBox is populated, then code will switch to .visible = True. All ComboBoxes have a default .value = [Blank] <--Could this be an issue?

    Try 1, Looking at .value
    Please Login or Register  to view this content.
    Try 2, Looking at .Visible
    Please Login or Register  to view this content.
    Both attempts are showing the same result [Staff1, Staff2, Staff3, Staff4, , , , , , &] not what I am looking for [Staff1, Staff2, Staff3, & Staff4].

    I have been trying to figure this out for 2 hours. Am I going about this the wrong way?

    Any help on this matter would be GREATLY appreciated!

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Using Multiple Combo Box Values to populate a cell (Excluding blank combo boxes)

    Untested, but something like this
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-11-2016
    Location
    Wisconsin
    MS-Off Ver
    07-360
    Posts
    53

    Re: Using Multiple Combo Box Values to populate a cell (Excluding blank combo boxes)

    Wow, that worked great! Thank you! I ended up changing it very slightly to get it going, here is what I had:
    Please Login or Register  to view this content.
    Any idea why the ElseIf wasn't working? Just out of curiosity to learn.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,525

    Re: Using Multiple Combo Box Values to populate a cell (Excluding blank combo boxes)

    Quote Originally Posted by mnadamn19 View Post
    Any idea why the ElseIf wasn't working? Just out of curiosity to learn.
    Which part?

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Using Multiple Combo Box Values to populate a cell (Excluding blank combo boxes)

    You are using the concatenation operator, &, in some of the expressions in your If/ElseIf statements.
    If posting code please use code tags, see here.

+ 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. Populate combo with values from one column and text boxes from other columns
    By Tea_4_2 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-15-2016, 07:33 PM
  2. [SOLVED] values in ActiveX combo boxes dependent on multiple criterias
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-11-2016, 11:18 AM
  3. populate a combo box with values of multiple columns from sheet 3
    By justlearning123 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-13-2015, 01:18 PM
  4. Complex concatenation of values from multiple combo boxes
    By swood15 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-06-2014, 06:59 PM
  5. Where to populate Combo Boxes
    By andrew c. in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-14-2011, 06:55 PM
  6. Best way to populate worksheet from 2 combo boxes
    By jswasson in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-07-2006, 08:25 AM
  7. [SOLVED] Combination of 2 combo boxes to populate 3rd
    By AJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-31-2005, 07:06 PM

Tags for this Thread

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