+ Reply to Thread
Results 1 to 10 of 10

IF AND / OR Statement for Data Validation rules

  1. #1
    Registered User
    Join Date
    01-29-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    IF AND / OR Statement for Data Validation rules

    Hi Everyone - this is my first post and it is a pleasure to now be a part of your community. I am a bit stuck however with a formula and I hope someone can help me!

    I am trying to set a data validation rule based on one cell meeting one either of two conditions, and another cell not meeting a condition for the error message to display but I am having no luck. I have used IF / OR / AND statments before in general excel but the logic seems to be different in data validation custom formulas?

    When cell I26 is selected for input I want an error message to display when one of either two conditions are met in cell C21 (in this case "Lifetime C", or 'Lifetime F"), and when cell F11 does not equal a particular date.

    I tried this and other formuals but none seem to work: =and(f11<>datevalue("31/12/2030"),or(C21="Lifetime D & O Commercial",c21="Lifetime D & O Financial))

    I have also tried 'dumbing down' the logic to meet only one condition in cell C21 and that didn't work either...

    Appreciate in advance any assistance anyone can give.

    Thanks

    Derek

  2. #2
    Registered User
    Join Date
    01-29-2014
    Location
    Maryland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: IF AND / OR Statement for Data Validation rules

    This is incredibly newbie of me, as it is my second post here: but have you considered the NOT function?

  3. #3
    Registered User
    Join Date
    01-29-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: IF AND / OR Statement for Data Validation rules

    Hi there

    No I haven't in what context would you apply it in this case?

  4. #4
    Registered User
    Join Date
    01-29-2014
    Location
    Maryland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: IF AND / OR Statement for Data Validation rules

    http://office.microsoft.com/en-us/excel-help/not-function-HP010062402.aspx]Try this page. Do you think it's what you're looking for, in regards to "another cell not meeting a condition for the error message to display"?

  5. #5
    Registered User
    Join Date
    01-29-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: IF AND / OR Statement for Data Validation rules

    Thanks for link but that doesn't really provide a result as far as I can see. Cell F11 only comes into play when one of either two conditions are met in cell C21.

    Cheers

  6. #6
    Registered User
    Join Date
    01-29-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: IF AND / OR Statement for Data Validation rules

    This is the dumbed down version with cell C21 needing to meet only one condition and it still doesn't work - the error message is displayed regardless!! =IF(AND(C21="Lifetime D & O Commercial"),F11<>47848).The date has been converted to general format is this version.

    Any ideas?

  7. #7
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: IF AND / OR Statement for Data Validation rules

    welcome to the forum, DPaton. i suppose "Lifetime C" & "Lifetime F" are shortforms? your formula suggest a longer text. for error to show when C21 is "Lifetime C" & F11 is blank, try:
    =AND(C21<>"Lifetime D & O Commercial",C21<>"Lifetime D & O Financial",F11<>--"31dec2030")

    or is it when C21 is ""Lifetime C" and F11 is 31 Dec 2030 that it has an error? if so, try:
    =OR(AND(C21<>"Lifetime D & O Commercial",C21<>"Lifetime D & O Financial"),F11<>--"31dec2030")

    i'll explain a little why the 2 formulas you have don't work:
    =AND(F11<>DATEVALUE("31/12/2030"),OR(C21="Lifetime D & O Commercial",C21="Lifetime D & O Financial"))
    the above needs F11 to not be 31dec2030. that should serve the purpose. but try not to use "31/12/2030". it will not work for someone whose region settings is MDY. by using AND, it must meet 1 of the 2 conditions. C21="Lifetime D & O Commercial" means the validation passes when C21 is so

    =IF(AND(C21="Lifetime D & O Commercial"),F11<>47848)
    again, C21 will pass the validation when it's "Lifetime D & O Commercial" AND when F11 is 31dec2030. the date now works for all settings but it's confusing. you can use:
    --"31dec2030"
    DATEVALUE("31dec2030")
    DATE(2030,12,31)

    i placed my 2 formulas in I26 & I27
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  8. #8
    Registered User
    Join Date
    01-29-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: IF AND / OR Statement for Data Validation rules

    Hi benishiryo - I visited your fine city recently and had a wonderful time (our regional office is located there...)

    Yes I redacted the text somewhat but the formula is the full version and thank you so much for the time and effort you have made! Basically if 'Lifetime C' OR 'Lifetime F' condtion is met AND the date in cell F11 IS NOT 31/12/2030 then the error message should be displayed. Cell F11 is only checked if cell C21 is 'Lifetime C' OR 'Lifetime F'.

    I hope I am explaining this properly - forgive me if not. Happy to provide you with more info if you need it.

    Cheers

    Derek

    Derek

  9. #9
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,156

    Re: IF AND / OR Statement for Data Validation rules

    glad you did, derek~ we're a "fine" city indeed! we fine people for the slightest things.

    i suppose my 2nd solution would work for you then. if it doesn't give a scenario on what C21 & F11 are, and it should give/not give an error. and if it's solved, do go to the Thread Tools -> Mark as Solved. thanks
    =)

  10. #10
    Registered User
    Join Date
    01-29-2014
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: IF AND / OR Statement for Data Validation rules

    Thanks benishiryo. I tried this formula which is a slight variation to your second solution and it did not work either.

    =OR(AND(C21="Lifetime D & O Commercial",C21="Lifetime D & O Financial"),F11<>DATEVALUE("30/12/2030")).

    OK so cell C21 is a drop down list of product types and cell F11 is the expiry date of the product which is manually input by the user. There are two products, 'Lifetime C' and 'Lifetime F' that must always have an expiry date of 31/12/2030 so I want the error message to show when another cell has been selected (in this case the $ input cell I26) since the product and expiry date cells have already been selected / input. It is only this scenario that the error message applies to. Hope this helps as I am finding it very frustrating... and thanks for all your help!

    I will definitely Mark as Solved when I have worked it out... Thanks again

    Derek

+ 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. Unable to prevent copy pasting data that does not conform to data validation rules
    By Sree Varun in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-25-2013, 10:41 PM
  2. Seeing which cells have Data Validation rules
    By marketshare in forum Excel General
    Replies: 5
    Last Post: 03-27-2011, 07:51 PM
  3. validation rules not working when someone copy paste data on validation cell
    By jthakrar in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-17-2010, 03:36 AM
  4. Replies: 2
    Last Post: 01-03-2010, 05:21 PM
  5. [SOLVED] Data Validation Rules
    By Louise in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-10-2006, 08:10 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