+ Reply to Thread
Results 1 to 11 of 11

Nested IF Function...why isnt it working?

  1. #1
    Registered User
    Join Date
    09-21-2013
    Location
    Reading, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Nested IF Function...why isnt it working?

    Hi,

    I'd be grateful if someone could point out what is going wrong with this formula...I've tried a number of ways including with nested AND with all six dates with IF functions and still no luck. I don't get errors just the wrong result.

    Essentially I want it to tell me if a specific date is between one of three ranges 01/01/13 - 31/03/13 = Spring, 01/04/13 - 31/08/13 = Summer, 01/09/13 - 31/12/13 = Winter

    Cell D4 = 02/02/13

    =IF(D4<=31/3/13,"SPRING",IF(D4<=31/8/13,"SUMMER","WINTER"))
    =IF(D4>=1/9/2013,"WINTER",IF(D4>=1/4/13,"SUMMER","SPRING"))

    The answer I get is Winter

    Many thanks

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

    Re: Nested IF Function...why isnt it working?

    Instead of 31/3/13, try DATEVALUE("31/03/2013").

    And be consistent ... although, if it looks like a valid date, TIMEVALUE should convert it ok


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

    Re: Nested IF Function...why isnt it working?

    Note that 31/3/13 is probably being treated as 31 divided by 3 divided by 13

    Regards, TMS

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Nested IF Function...why isnt it working?

    OR use DATE(). So your first formula would look like

    =IF(D4<=DATE(2013,3,13),"SPRING",IF(D4<=DATE(2013,8,31),"SUMMER","WINTER"))

  5. #5
    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,946

    Re: Nested IF Function...why isnt it working?

    Hi and welcome to the forum

    try this...
    =IF(D4<=DATE(2013,8,31),"SPRING",IF(D4<=DATE(2013,8,31),"SUMMER","WINTER"))
    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

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

    Re: Nested IF Function...why isnt it working?

    I also note that your second date is 5 months after the first data ... long season?

    Regards, TMS

  7. #7
    Registered User
    Join Date
    09-21-2013
    Location
    Reading, UK
    MS-Off Ver
    Excel 2010
    Posts
    41

    Re: Nested IF Function...why isnt it working?

    Thanks for the replies and welcome!

    adding DATE has worked and it is giving the expected results, however I forgot about blank cells...
    So have amended the formula to this:

    =IF(AND(D5>=DATE(2013,1,1),D5<=DATE(2013,3,31)),"SPRING",IF(AND(D5>=DATE(2013,4,1),D5<=DATE(2013,8,31)),"SUMMER",IF(AND(D5>=DATE(2013,9,1),D5<=DATE(2013,12,31)),"WINTER","")))

    Thanks again for your help!

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

    Re: Nested IF Function...why isnt it working?

    You're welcome.

  9. #9
    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,946

    Re: Nested IF Function...why isnt it working?

    Happy to help

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

    Re: Nested IF Function...why isnt it working?

    For blank cells correction you can use:
    =IF(D6="",""....

    the new formula becomes:
    =IF(D6="","",IF(D6<=DATE(2013,3,31),"SPRING",IF(D6<=DATE(2013,8,31),"SUMMER",IF(D6<=DATE(2013,12,31),"WINTER",""))))
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  11. #11
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Nested IF Function...why isnt it working?

    Quote Originally Posted by PJC2013 View Post
    Thanks for the replies and welcome!

    adding DATE has worked and it is giving the expected results, however I forgot about blank cells...
    So have amended the formula to this:

    =IF(AND(D5>=DATE(2013,1,1),D5<=DATE(2013,3,31)),"SPRING",IF(AND(D5>=DATE(2013,4,1),D5<=DATE(2013,8,31)),"SUMMER",IF(AND(D5>=DATE(2013,9,1),D5<=DATE(2013,12,31)),"WINTER","")))

    Thanks again for your help!
    Try this way... It looks 75% shorter and more elegant than that formula

    =IF(D5,LOOKUP(MONTH(D5),{1,4,9},{"Spring","Summer","Winter"}),"")

+ 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. my if formula isnt working
    By zazzz in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-14-2013, 04:14 AM
  2. Part of function isnt working
    By hawkinsr86 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-03-2012, 07:20 PM
  3. VBA - Why isnt this working?
    By Chris424 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-28-2008, 10:19 AM
  4. Replies: 1
    Last Post: 09-30-2005, 09:05 AM
  5. [SOLVED] AutoFill isnt working?
    By M.L in forum Excel General
    Replies: 7
    Last Post: 06-16-2005, 04:05 PM

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