+ Reply to Thread
Results 1 to 10 of 10

Combining a data validation list with a custom formula (including error message)

  1. #1
    Registered User
    Join Date
    03-28-2014
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    6

    Combining a data validation list with a custom formula (including error message)

    Hi,

    I have problem that I can’t solve.

    I want to combine a data validation list with a custom formula (including error message).

    In the cells e3:e5 I want to have drop down list with the choice “low”, “medium” and “high” but you should only be able to select a value (“low”, “medium” and “high”) once. That is to say, you have chosen value “low” in the first cell, you should receive an error message, that says something about only unique values are allowed, if you choose low again.

    Thanks in advance

  2. #2
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Combining a data validation list with a custom formula (including error message)

    If there are only 3 cells and they can only be one of the three, why not fix them?
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  3. #3
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,459

    Re: Combining a data validation list with a custom formula (including error message)

    Try:
    Validation in E3:
    Allow: Custom
    Formula:=OR(E3="low",E3="medium",E3="high")
    In E4:
    Formula:=AND(OR(E4="medium",E4="high",E4="low"),E4<>E3)
    In E5:
    Formula:=AND(OR(E5="low",E5="medium",E5="high"),E5<>E3,E5<>E4)
    Quang PT

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Combining a data validation list with a custom formula (including error message)

    Try this...

    Enter the selections in a range of cells, say Z2:Z4


    Enter this array formula** in AA2 and copy down to AA4:

    =IFERROR(INDEX(Z:Z,SMALL(IF(ISNA(MATCH(Z$2:Z$4,E$3:E$5,0)),ROW(Z$2:Z$4)),ROWS(AA$2:AA2))))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Now, setup the drop down list...

    Select the range E3:E5
    Data Validation
    Allow: List
    Source: =OFFSET(AA$2,,,COUNTIF(AA$2:AA$4,"?*"))
    OK out

    This will restrict the selections in the drop down list so that once a selection is made that selection will be removed from the list and no duplicates can be selected.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,289

    Re: Combining a data validation list with a custom formula (including error message)

    Or take a look at this
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  6. #6
    Registered User
    Join Date
    03-28-2014
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Combining a data validation list with a custom formula (including error message)

    Quote Originally Posted by bebo021999 View Post
    Try:
    Validation in E3:
    Allow: Custom
    Formula:=OR(E3="low",E3="medium",E3="high")
    In E4:
    Formula:=AND(OR(E4="medium",E4="high",E4="low"),E4<>E3)
    In E5:
    Formula:=AND(OR(E5="low",E5="medium",E5="high"),E5<>E3,E5<>E4)

    Hi again,

    thanks for the proposal, but it will not solve the problem as I understand it, because I also want to have a drop down list.

  7. #7
    Registered User
    Join Date
    03-28-2014
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Combining a data validation list with a custom formula (including error message)

    Quote Originally Posted by popipipo View Post
    Or take a look at this
    Thanks for a good proposal, but it will not solve the problem fully. Since it should always be possible to select all options but it should be an error message if you choose an option that is already selected.

  8. #8
    Registered User
    Join Date
    03-28-2014
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Combining a data validation list with a custom formula (including error message)

    Quote Originally Posted by Tony Valko View Post
    Try this...

    Enter the selections in a range of cells, say Z2:Z4


    Enter this array formula** in AA2 and copy down to AA4:

    =IFERROR(INDEX(Z:Z,SMALL(IF(ISNA(MATCH(Z$2:Z$4,E$3:E$5,0)),ROW(Z$2:Z$4)),ROWS(AA$2:AA2))))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

    Now, setup the drop down list...

    Select the range E3:E5
    Data Validation
    Allow: List
    Source: =OFFSET(AA$2,,,COUNTIF(AA$2:AA$4,"?*"))
    OK out

    This will restrict the selections in the drop down list so that once a selection is made that selection will be removed from the list and no duplicates can be selected.
    Thanks for a good proposal, but it will not solve the problem fully. Since it should always be possible to select all options but it should be an error message if you choose an option that is already selected.

  9. #9
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Combining a data validation list with a custom formula (including error message)

    I think the above solutions are the only ones available to you unless you want to resort to a VBA solution and that would only work if the user enables macros.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  10. #10
    Registered User
    Join Date
    03-28-2014
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Combining a data validation list with a custom formula (including error message)

    Quote Originally Posted by ChemistB View Post
    I think the above solutions are the only ones available to you unless you want to resort to a VBA solution and that would only work if the user enables macros.

    I see. A VBA solution would be great, could anyone help me 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. Replies: 0
    Last Post: 03-10-2013, 11:17 PM
  2. Data Validation List and Custom formula in 1 cell
    By murugavelmsc in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-11-2013, 02:50 AM
  3. Replies: 0
    Last Post: 01-09-2013, 11:44 AM
  4. Replies: 3
    Last Post: 07-20-2012, 09:52 AM
  5. Data Validation (Combining custom text and named range)
    By stuart010 in forum Excel General
    Replies: 1
    Last Post: 12-13-2011, 06: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