+ Reply to Thread
Results 1 to 4 of 4

IF(AND()) with date as numbers...

  1. #1
    Registered User
    Join Date
    05-12-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    14

    IF(AND()) with date as numbers...

    Hello again guys...

    I'm having a problem with the IF /AND statement...

    I have a column with the hours of the day (0 to 23) and I need to have to periods, from 8 to 20 and from 21 to 7.... as well as other true requirements already implemented.

    Now... the complete formula for the morning period is done and it works:

    =IF(AND(F2<$O$6;G2>$P$6;B2>=8;B2<=20);"P5";"OK")

    The last AND expression is the hours range.. The problem is the evening problem....

    =IF(AND(F2<$O$6;G2>$P$6;B2>=0;B2<=7);"P5";"OK") -> With this I only miss the 21,22 and 23 hours... the problem is how to... is there a way to keep all the ANDs and incorporate one OR for the last statement?

    Many thanks for all the experts out there trying to help the newbies
    Last edited by Dieneces; 05-15-2012 at 10:59 AM. Reason: Solved

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: IF(AND()) with date as numbers...

    How about including an OR:

    =IF(AND(F2<$O$6;G2>$P$6;OR(B2>=21;B2<=7));"P5";"OK")
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: IF(AND()) with date as numbers...

    Maybe change this
    =IF(AND(F2<$O$6;G2>$P$6;B2>=0;B2<=7);"P5";"OK")
    to this
    =IF(AND(F2<$O$6;G2>$P$6;OR(B2>=21;B2<=7));"P5";"OK")

  4. #4
    Registered User
    Join Date
    05-12-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    14

    Re: IF(AND()) with date as numbers...

    .... I tried to use the OR in three different ways some with errors some with no results... Now I see what I was doing wrong... I was trying to put the OR outside the AND (doesn't make any sense I know... it as by mistake #|)

    Many thanks for thw wise and quick replys.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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