+ Reply to Thread
Results 1 to 6 of 6

Can't get SUBSTITUTE Data Validations to work with OR function

  1. #1
    Registered User
    Join Date
    09-11-2023
    Location
    Leicester
    MS-Off Ver
    365
    Posts
    3

    Can't get SUBSTITUTE Data Validations to work with OR function

    Hi All,

    Can't seem to hit on the right combination for this one - I'm sure it'll turn out to be something obvious but I'm going round in circles here.
    I'm using the SUBSTITUTE formula for data validation to produce dependent drop-down lists, but have run up against the 256 character limit for the DV box.
    Therefore, I'm trying to shorten the statement by incorporating an OR function but can't seem to get it to work.

    The first part of the Data Validation formula goes something like this:

    =stuff_lk (where stuff_lk is a named range on a lookup sheet that contains the items to be used in the next drop down list)

    So for example, column C in the data table will allow the selection of "phonetic", "numeral" plus a few others from a drop-down list as these are the values in stuff_lk

    This is then used as a dependent value for the drop down list in column D of the data table, which has DV something like this:

    =INDIRECT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($C3,"Phonetic","phon_lk"), "Alphabetical","phon_lk"),"Letters","phon_lk"),"Numeral","num_lk"))

    The idea being that the drop-down list selection in column D gives a set of values from the specific named range that relates to the value of column C. This works fine up until the point that I have had to add more values to column C and run up against the character limit for data validation.
    As can be seen, some of the values in column C will actually share a corresponding value in column D.

    For example, the values of "Phonetic", "Alphabetical" and "Letters" should all give values from phon_lk in column D via the data validation. This would cut down on the text in the DV box and not run up against the character limit if I could use some kind of OR statement.

    E.g. =INDIRECT(SUBSTITUTE($C3,("Phonetic" OR "Alphabetical" OR "Letters"),"phon_lk"))

    I know the syntax is completely wrong above, but it's just trying to demonstrate what I'm attempting to achieve.

    I've looked at INDEX/MATCH and XLOOKUP but none seem appropriate as the named ranges for column D are all vastly different lengths and bear no relation to each other.

    Is there a way to achieve this that I'm completely missing here? I've attached a small mock-up sheet using just a few SUBSTITUTE validations

    Any help would be hugely appreciated.

    Many thanks

    Iain
    Attached Files Attached Files

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Can't get SUBSTITUTE Data Validations to work with OR function

    You have to cheat.

    1 Add a column to the tbl_primary
    2 Insert the links to the secondary table(s)
    3 Create a Named Range that refers to the body of the tbl_primary
    in this example, dnrTMS
    4 Use the DV formula: =INDIRECT(VLOOKUP($C3,dnrTMS,2,0))

    See the updated example
    Attached Files Attached Files
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    09-11-2023
    Location
    Leicester
    MS-Off Ver
    365
    Posts
    3

    Talking Re: Can't get SUBSTITUTE Data Validations to work with OR function

    That's an excellent workaround - many thanks TMS. That was driving me up the wall.

    Cheers

    Iain

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Can't get SUBSTITUTE Data Validations to work with OR function

    You're welcome. Thanks for the rep.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,420

    Re: Can't get SUBSTITUTE Data Validations to work with OR function

    Note that the reason for doing it this way is that the DV doesn't seem happy about using INDIRECT, VLOOKUP and a Structured Table. And I seem to recall that it's not keen on using INDIRECT with Dynamic Named Ranges.

    This approach means that, strictly speaking, you have a fixed Named Range but the size will automatically adjust if/when the Table increases in size.

    The examples in the updated sample file demonstrate that, in theory, what you expect to work should work but doesn't.

  6. #6
    Registered User
    Join Date
    09-11-2023
    Location
    Leicester
    MS-Off Ver
    365
    Posts
    3

    Re: Can't get SUBSTITUTE Data Validations to work with OR function

    I do get the impression sometimes that DV is one of the features that MS have ignored for a while. Probably high time it got a revamp.

+ 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] VLOOKUP with SUBSTITUTE function don't work
    By sunjam in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 08-26-2021, 09:39 AM
  2. Replies: 2
    Last Post: 09-27-2020, 11:00 PM
  3. [SOLVED] Substitute formula not work
    By vasc in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-02-2020, 02:26 AM
  4. Replies: 5
    Last Post: 04-10-2014, 06:43 AM
  5. [SOLVED] Substitute - i think might work but i am not sure how to use it
    By singer.joseph in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-19-2013, 06:21 AM
  6. Validations Based On Previous Validations
    By PhatPhil in forum Excel General
    Replies: 5
    Last Post: 11-16-2009, 04:19 AM
  7. Trim, clean and substitute function do not work for these data
    By radzian in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-02-2008, 07:59 AM

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