+ Reply to Thread
Results 1 to 5 of 5

Dynamic ComboBox used as index into variable length list

  1. #1
    Registered User
    Join Date
    05-31-2013
    Location
    Fort Wayne, IN, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Dynamic ComboBox used as index into variable length list

    I have a worksheet that contains tabular data. Column A contains an ID# for each row. There can be multiple rows with the same ID# so what I want to do (on a different sheet) is have a combo box whose input range is dynamically updated to include a list of numbers from 1 to the number of entries in the tabular data that have an ID# matching a particular cell's value.

    So, for instance, assume the tabular data is on SheetA, and the combo box and cell with the value to match are on SheetB.
    If the value to be matched is 1200, and SheetA has six rows with the ID# 1200, I want the combo box to list six entries; 1, 2, 3, 4, 5, 6.
    If the value matches only two rows, the combo box would list two entries; 1, 2.

    That way, I can use the combo box's cell link value to populate SheetB fields from the nth SheetA row, as selected by the combo box (This part I think I know how to do)

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Dynamic ComboBox used as index into variable length list

    Hi jtyoder,

    It is easier to explain and do these problems if you give us a sample workbook, showing your data layout and expected results.

    From the reading of your problem, I'd be first looking on the net for "Cascading Dropdown" or "Dependent Dropdown".

    If the above topics don't work then an Advanced Filter that rebuilds your dropdown list using a VBA Event might be a great answer. If you make the Advanced Filter range a Dynamic Named Range it could be perfect for the way I see your problem.

    If none of the above makes sense, attach a sample workbook by clicking on "Go Advanced" below the message area and then on the Paper Clip Icon above the advanced message area.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    05-31-2013
    Location
    Fort Wayne, IN, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Dynamic ComboBox used as index into variable length list

    Thanks for the quick response MarvinP!

    Unfortunately the dependent dropdown solution doesn't work since it deals with populating the combo box with values from a range rather than a sequential index into the matching rows in the range.

    The advanced filter also doesn't quite get me there either since I only want one of the total rows in SheetA with the matching ID#, not all of them.

    I'll try to obfuscate my data and attach a sample.

  4. #4
    Registered User
    Join Date
    05-31-2013
    Location
    Fort Wayne, IN, USA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Dynamic ComboBox used as index into variable length list

    I've attached a sample workbook with dummy data.

    If you look on the Risk tab, column P contains the combo box in question. Based on the risk number selected in A1, I want the "Select Mitigation Step" combo box to have a list of numbers representing the individual mitigation steps, from the "Mitigations" tab, that have an ID number in column A matching the selected risk.

    So if Risk tab cell A1 contains '1', the Select Mitigation Step combo box will have the numbers 1 through 8, because the Mitigations tab lists 8 steps associated with risk 1.

    If Risk tab cell A1 contains '2', the combo box would only have 1 through 4 in its list because there are only 4 mitigation steps associated with risk 2.

    Once I can get the combo box populating properly I can use the selected number from the combo box to populate the Current Value fields (1-14) in the Mitigation Step Update Table by pulling the appropriate data from the Mitigations tab.
    Attached Files Attached Files

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: Dynamic ComboBox used as index into variable length list

    OK - here you go....

    I've created an Advanced Filter on your Mitigations sheet so I could filter out the number selected on the Risk sheet. Advanced Filters are on the Data Tab. To make it easier to grab all the data I created a Dynamic Named Range called MitigationTable. See it using the Formulas Tab and the Names Manager. It is Dynamic because it will grow or shrink based on the number of rows you have in your table.
    Look at cell Q2 on the Mitigations sheet to see how the Risk sheet and advanced filter fit together.

    I then created a macro to do the Advanced Filter and called it RedoAdvancedFilter. It uses the MitigationTable and the number you type in A1 on the Risks sheet to do the filter.

    Then I created another Dynamic Named Range called MitigationList which is the filtered words from the filtered data. This Name is then used in Cell P3 for your dropdown. I've changed P3 to a Validation Cell instead of a ComboBox to make the problem easier. If you are good enough with VBA you can change it back and use a ComboBox.

    Lastly - when you change the cell A1 on the Risks sheet I fire the advanced filter that then changes the data and using the DNR makes the MitigationList longer/shorter and ends up what you want (I think).

    Here it all is in the attached.


    I've first created two Dynamic Named Ranges to make formulas easier.

+ 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. Replies: 3
    Last Post: 11-07-2012, 10:26 AM
  2. Replies: 0
    Last Post: 09-28-2011, 02:52 AM
  3. Excel 2007 : Multiple Variable Length Lists to 1 List
    By Sarah12 in forum Excel General
    Replies: 5
    Last Post: 02-10-2011, 08:07 PM
  4. Copy formula - for a variable-length list
    By luis33 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-13-2010, 07:58 PM
  5. Replies: 1
    Last Post: 11-10-2009, 03:24 AM
  6. Dynamic List for combobox
    By T De Villiers in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2008, 05:49 AM
  7. Combobox with a dynamic list
    By Arishy in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 08-12-2005, 10:05 AM
  8. Filling combobox with variable length list
    By Denny Behnfeldt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-02-2005, 03:06 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