+ Reply to Thread
Results 1 to 8 of 8

populating combobox based on another combobox selection

  1. #1
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    340

    populating combobox based on another combobox selection

    Hi, attached is a file that Im making to make it easier to print labels. I need some help on coding the second combobox based on what is selected in the first combobox. EG:
    Kastle Meyer Reagent selected in first combobox
    Lot no will have KMR150713 as selection

    1% (w/v) Iodine selected in first combobox
    Lot no will have 365B as selection

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Moderator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    365
    Posts
    21,292

    Re: populating combobox based on another combobox selection

    You hit the nail on the head when you said "coding". However, the file you attached does not have any code (yet).

    You need to provide a little more detail about how you want this to work. So based on the selection in the first combobox, you want the second combobox to have a specific selection automatically? Will the second combobox always have the same list of items, and just the selection changes? I assume that you want the user to be able to make a different selection than the one chosen automatically, otherwise there wouldn't be any point in making this a combobox.
    Jeff
    | | |?| |?| |?| |?| | |:| | |?| |?|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    340

    Re: populating combobox based on another combobox selection

    Hi Jazzer, I only manage to get the first combobox code working, that's why there isn't much code inside. Yes, based on the selection of combobox 1, combobox 2 will have a list of selection available which would not appear if a different selection was made at combobox 1. EG:

    Combobox 1 selection = Kastle Meyer Reagent
    Combobox 2 will have a list of items that can be selected (KMR12345, KMR45678, KMR99900 etc). I only listed 1 in the above thread, maybe that's why it was confusing.

    If Combobox 1 selection = Iodine
    Combobox 2 selection will only have items like 365A, 365B, 365C etc, and not KMR12345 etc

    Hope this makes it clear

  4. #4
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,667

    Re: populating combobox based on another combobox selection

    If your Combobox 2 only has one possibility for a given Combobox 1 selection, you don't need Combobox 2 - at most, all you need is a Textbox (and probably not even that, since you can populate the cell directly. And, in that case, you'd probably do better to use a dropdown formfield instead of Combobox 1 and an IF field to conditionally output the text, in a document with 'filling in firms' protection applied. No macros are required for such a document. Plus it'll work on Macs, which ActiveX controls won't do.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    340

    Re: populating combobox based on another combobox selection

    Hi Jazzer, how do I do the drop down form field? I inserted the field and added the items for selection, but couldn't click it to show the selection

  6. #6
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,667

    Re: populating combobox based on another combobox selection

    If you're using ActiveX controls, you need to exit design mode.

  7. #7
    Forum Contributor
    Join Date
    05-06-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    340

    Re: populating combobox based on another combobox selection

    ok, i got up to the part of making it work. How do I know insert the IF field as you suggested?
    Attached Files Attached Files

  8. #8
    Forum Guru macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,667

    Re: populating combobox based on another combobox selection

    As I said:
    If your Combobox 2 only has one possibility for a given Combobox 1 selection, you don't need Combobox 2
    Your document, however, depicts two possibilities for the 'Lot No' dropdown. Presumably other selections from the first dropdown, which lists 'Kastle Meyer Reagent', '1% (w/v)Iodine' and 'Acid Phosphatase Reagent' will also have one or more options. Accordingly, you can't simply use a single dropdown formfield and an IF field to control the output. Regardless of whether you use ActiveX controls, formfields or content controls, a macro will be required. All you need to do is decide which tool best suits you needs and stick with that.

+ 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] How do I populate a specific range in one ComboBox based of selection of another ComboBox?
    By gmr4evr1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-04-2015, 04:32 PM
  2. [SOLVED] Change next ComboBox list based on previous ComboBox selection
    By SteveTheFish in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2015, 11:23 PM
  3. Populating Combobox based on Combobox selection from EXCEL worksheet
    By JChaney17 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-04-2014, 08:14 AM
  4. [SOLVED] Pre populating a userform from excel based on combobox selection
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2013, 12:09 PM
  5. Removing Duplicates from ComboBox and Populating one combobox based on another
    By kbmtech in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-27-2010, 11:17 PM
  6. Populating the list in a combobox based off the value chosen in another combobox
    By Mervil in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-21-2010, 11:50 AM
  7. Populating a userform based on a combobox selection
    By blindzero678 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-22-2010, 03:37 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