+ Reply to Thread
Results 1 to 9 of 9

nested IF statement

  1. #1
    Registered User
    Join Date
    06-01-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    2

    nested IF statement

    Hi,

    Please help, I need to nest the following 3 IFs:

    =IF(L3=1,"n/a")
    =IF(L3=2, F4+28)
    =IF(L3=3, F4+182)

    Thanks
    nigec

  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,510

    Re: nested IF statement

    =IF(L3=1,"n/a",IF(L3=2, F4+28,IF(L3=3, F4+182,"")))


    Regards, TMS
    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
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,944

    Re: nested IF statement

    Use this if there will only ever be 3 values in L3
    =IF(L3=1,"n/a",IF(L3=2, F4+28,F4+182))
    otherwise use this...
    =IF(L3=1,"n/a",IF(L3=2, F4+28,IF(L3=3,F4+182,""))))
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    06-01-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: nested IF statement

    Thanks Guys! 1 more question please, if I wanted to add 6 months to a date (i.e. Feb 28th to Aug 28th, rather than IF(L3=3,F4+182,"") how would I do this?

    Thanks again

  5. #5
    Registered User
    Join Date
    06-01-2013
    Location
    Columbus, ms
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: nested IF statement

    You could also use the following which may be cleaner
    =choose(L3,"n/a",F4+28,F4+182)

    If L3 can equal 4 down the road you can simply add a fourth comma rather then further nesting an if statement.

  6. #6
    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,510

    Re: nested IF statement

    =DATE(YEAR(F4),MONTH(F4)+6,DAY(F4))


    Regards, TMS

  7. #7
    Registered User
    Join Date
    06-01-2013
    Location
    Columbus, ms
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: nested IF statement

    Try date(year(f4),month(F4)+6,day(F4))

    I can't try this out right now but the problem I see if the the month is after June you will get into the month being 13. I'm not sure what excel does with that but you could try the following.
    date(year(f4)+if(month(f4)>6,1,0),choose(month(f4),7,8,9,10,11,12,1,2,3,4,5,6),day(f4))

  8. #8
    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,510

    Re: nested IF statement

    @Spitzerpl: I'm pretty sure it rolls the year over.

    See http://office.microsoft.com/en-gb/ex...010062283.aspx


    Regards, TMS
    Last edited by TMS; 06-01-2013 at 10:32 PM.

  9. #9
    Registered User
    Join Date
    06-01-2013
    Location
    Columbus, ms
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: nested IF statement

    It sure does. Good to know. Thanks!

+ 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