+ Reply to Thread
Results 1 to 6 of 6

Thread: Nested IF THEN ELSE Statement

  1. #1
    Registered User
    Join Date
    02-06-2012
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Nested IF THEN ELSE Statement

    I need help creating the following statement:

    IF(U2<>"",DATEDIF(U2,TODAY(),"D")

    ELSE IF(Q2<>"",DATEDIF(Q2,TODAY(),"D")

    ELSE IF(M2<>"",DATEDIF(M2,TODAY(),"D")

    ELSE(DATEDIF(E2,TODAY(),"D")

    END IF

    Thank you!

  2. #2
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,202

    Re: Nested IF THEN ELSE Statement

    I think ...

    =IF(U2<>"",DATEDIF(U2,TODAY(),"D"),IF(Q2<>"",DATEDIF(Q2,TODAY(),"D"),IF(M2<>"",DATEDIF(M2,TODAY(),"D "),(DATEDIF(E2,TODAY(),"D"))))


    Regards

  3. #3
    Valued Forum Contributor tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    USA
    MS-Off Ver
    Excel 2003 - 2007
    Posts
    2,348

    Re: Nested IF THEN ELSE Statement

    Alternate formula:
    =IF(COUNT(E2,M2,Q2,U2)=0,"",DATEDIF(IF(U2<>"",U2,IF(Q2<>"",Q2,IF(M2<>"",M2,E2))),TODAY(),"D"))
    Hope that helps,
    ~tigeravatar

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

  4. #4
    Registered User
    Join Date
    02-06-2012
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Nested IF THEN ELSE Statement

    You are the bomb!! I removed the extra space after one of the "D "s and it worked beautifully. Thanks so much.

    =IF(U2<>"",DATEDIF(U2,TODAY(),"D"),IF(Q2<>"",DATEDIF(Q2,TODAY(),"D"),IF(M2<>"",DATEDIF(M2,TODAY(),"D "),(DATEDIF(E2,TODAY(),"D")))))

  5. #5
    Registered User
    Join Date
    02-06-2012
    Location
    Sacramento, CA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Nested IF THEN ELSE Statement

    This works great, as well ... and allows for the event when all 4 cells are blank. Thanks so much!

  6. #6
    Forum Guru TMShucks's Avatar
    Join Date
    07-15-2010
    Location
    Manchester, England
    MS-Off Ver
    MSO 2003 & 2007
    Posts
    6,202

    Re: Nested IF THEN ELSE Statement

    You're welcome.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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.2.0