+ Reply to Thread
Results 1 to 4 of 4

Invalid IF statement?

  1. #1
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194

    Invalid IF statement?

    If cell 13 contains 150, why does this formula display the value as 1?

    =IF(C13>0,1,IF(C13>100,2,0))


    It doesn't make sense to me.

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Invalid IF statement?

    I suspect the 150 is actually stored as Text and Text > Number.

    Also you need to order your IFs correctly given an IF will exit upon first True, ie your >100 would never be actioned (given >0 test would hold True first)

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Invalid IF statement?

    As DO said, it never gets to the second IF statement, reorder like so

    =IF(C13>100,2,IF(C13>0,1,0))
    Does that work for you?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

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

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Invalid IF statement?

    @ChemistB, thanks for adding some clarity... all I can say is:

    WOW - the Text comment on my part is a pretty spectacular howler especially when you consider I even answered the problem in the remainder of the post !
    Time for me to take a break methinks...

+ 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