+ Reply to Thread
Results 1 to 12 of 12

Filtered Data Validation Lists

  1. #1
    Registered User
    Join Date
    01-25-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Filtered Data Validation Lists

    I need to find a way to list valid 2nd column values from a 2 column range, by filtering using the first column in the the list. for example:

    A Apple
    A Aardvark
    A Animal
    B Banana
    B Baboon
    B Basketball
    B Balloon
    B Barium
    C Carrot
    C Cat
    C Car
    C Charity

    On another sheet, on each row, a validated cell lists values from the second column whose first column matches the value from a cell in the same row

    So a cell value of C would list only carrot, cat, car and charity in the drop-down.

    I would have thought a formula like:
    Please Login or Register  to view this content.
    might work, but the data validation window doesn't like it. (and won't let me do array formula - ctrl+shift+enter or {...})

    I can't re-arrange the look-up data and i'd like to avoid VBA if possible. (it will be added to, so will need to be dynamic and in reality there might be more columns)

    Is there a way to automatically generate range names in this layout, then use indirect for the validation?

    Much appreciated

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,798

    Re: Filtered Data Validation Lists

    Yes, define a named range called A covering Apple, Aardvark and Animal, a range called B covering Banana to Barium, and a range C covering Carrot to Charity. Then if Sheet1!A1 contains one of those letters, your data validation source list for B1 (say) should contain the formula =INDIRECT(Sheet1!$A$!).

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    01-25-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Filtered Data Validation Lists

    I cant do this manually, i have hundreds of entries in reality, that's why i asked if there was a way to automatically generate range names for this layout.
    Also, they may get shuffled/sorted, so accounting for that too would be useful.

  4. #4
    Valued Forum Contributor
    Join Date
    05-19-2010
    Location
    Ontario, Canada
    MS-Off Ver
    Excel 2010
    Posts
    391

    Re: Filtered Data Validation Lists

    check out this site there may be somthing in here that will help
    https://sites.google.com/a/madrocket...ssistant/files

  5. #5
    Forum Expert Palmetto's Avatar
    Join Date
    04-04-2007
    Location
    South Eastern, USA
    MS-Off Ver
    XP, 2007, 2010
    Posts
    3,978

    Re: Filtered Data Validation Lists

    Sounds like you could make use of this excellent approach by Jerry Beaucaire: Auto-Complete Data Validation
    Palmetto

    Do you know . . . ?

    You can leave feedback and add to the reputation of all who contributed a helpful response to your solution by clicking the star icon located at the left in one of their post in this thread.

  6. #6
    Registered User
    Join Date
    01-25-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Filtered Data Validation Lists

    Thanks that's great. AutoCompleteDataValidation(SortOf)2.xls is closest to what i want to do, although I only want a single-stage dropdown, but I will reference another cell value for the filter.

    So my revised formula is:
    Please Login or Register  to view this content.
    I think I understand what it's supposed to do, It looks for the first entry in the list using the A1&"-*" bit, then the last entry using the Approx. match A1&"-zzz" bit.
    This means the list has to be sorted alphabetically, but that's fine.

    Where PartList is a list of data in the following format:

    A-Apple
    A-Aardvark
    A-Animal
    B-Banana
    B-Baboon
    B-Basketball
    B-Balloon
    B-Barium
    C-Carrot
    C-Cat
    C-Car
    C-Charity

    Made with '=A1&"-"&B1 formula in column next to existing data.

    (I realise for this example it's a bit redundant, but this isn't my real data)

    However, I get this error (Which prevents it from passing):

    /!\ You may not use reference operators (such as unions, intersections, and ranges) or array constants for Data Validation criteria
    [OK]

    Does anyone know if I've made a mistake or how to get around this?

  7. #7
    Registered User
    Join Date
    01-25-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Filtered Data Validation Lists

    Sorry to bump, but i really need to know and this seems like it might work.

  8. #8
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Filtered Data Validation Lists

    Hi

    Selection criteria in Sheet1:A1 (C)
    Data in Sheet2!A:A
    Sheet2!B1: =IF(LEFT(A1,1)=Sheet1!$A$1,ROW(),"") - copy down
    Sheet2!D1: =IF(ROW()>COUNT(B:B),"",INDEX(A:A,SMALL(B:B,ROW())))

    Then create a defined name with the Refers to: =OFFSET(Sheet2!$D$1,0,0,COUNT(Sheet2!$B:$B),1)

    See how that goes.

    rylo

  9. #9
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,615

    Re: Filtered Data Validation Lists

    Pl see the attached fle.
    Using same sheet and helper cells validation done in Sheet1.
    Using code for worksheet change event validation is done in Sheet2.

    You can use which is convenient for you.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-25-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Filtered Data Validation Lists

    Answer:
    A1 = lookup value
    PartListWithGroups = Part list with group IDs (2 columns)
    PartListGroups = Fist column of above (Just the IDs)

    NOTE: THE DATA MUST BE SORTED BY ID!

    Please Login or Register  to view this content.
    It's surprisingly simple, like defining a draw region on a canvas. OFFSET uses:
    • PartListWithGroups - see above (canvas size)
    • MATCH to find the offset of the first value matching the lookup value (A1) in the list (y position)
    • OFFSET offsets the returned column by 1 so it lists the parts rather than the groups (x position)
    • COUNTIF to define the number of matching entries in the list. (draw height)
    • OFFSET only returns one column (draw width)

    Result - a dropdown list with a subset of data from a list without any whitespace.
    Last edited by Nintynuts; 01-27-2012 at 10:46 AM.

  11. #11
    Registered User
    Join Date
    01-25-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Filtered Data Validation Lists

    Okay, it's not working as perfectly as I initially thought.

    I think excel has a bug

    when the 'rows' (row offset) value goes above 40 the alignment starts to mess up.

    Can anyone else verify this? Does anyone know how to inform Microsoft this needs fixing if it's confirmed?

    I've tried to export my document to openoffice format and to import the xlsx to google docs and openoffice, but nothing has worked.

  12. #12
    Registered User
    Join Date
    01-25-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Filtered Data Validation Lists

    Is anyone else able to confirm this as a bug?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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