+ Reply to Thread
Results 1 to 3 of 3

Need help populating second combobox based on value in first

  1. #1
    Registered User
    Join Date
    09-22-2009
    Location
    Manchester, England
    MS-Off Ver
    Excel 2003
    Posts
    1

    Unhappy Need help populating second combobox based on value in first

    Hello everyone - first time here.

    I've got a userform that becomes visable when the workbook opens, and on this form I require 2 comboboxes, the first must allow the user to select a value from column A:A on sheet1. I would then like combobox 2 to only show the values in column B:B on sheet 1 that apply, allowing one of these to be selected.

    I'm at a point where I've got the boxes populating with all values, but have no idea how to make only valid combinations possible.

    For example if the data was:

    Column A Column B
    A 1
    A 2
    A 3
    B 4
    B 5
    B 6

    ...I would only like options 4,5,6 to be available in combobox 2 if "A" is selected in combobox 1.

    Hope this is all clear.

    Thanks in advance.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Need help populating second combobox based on value in first

    To best describe or illustrate your problem you would be better off attaching a dummy workbook, the workbook should contain the same structure and some dummy data of the same type as the type you have in your real workbook - so, if a cell contains numbers & letters in this format abc-123 then that should be reflected in the dummy workbook.

    If needed supply a before and after sheet in the workbook so the person helping you can see what you are trying to achieve.

    Doing this will ensure you get the result you need!

    This demonstrates one way using Listboxes, but can easily be applied to ComboBoxes
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need help populating second combobox based on value in first

    Hello Patrick3001,

    The following is from the attached workbook. This workbook is based on your ComboBox question. The first ComboBox determines has "A" and "B". The selection from this ComboBox loads the second ComboBox with the contents of that of that column. The code determines the size of the column to be loaded. This allows for the ranges to dynamic and any changes to the worksheet are reflected on the UserForm.

    UserForm Code
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ 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