+ Reply to Thread
Results 1 to 5 of 5

Strange Boolean If function result

  1. #1
    Registered User
    Join Date
    11-27-2010
    Location
    Madrid, Spain
    MS-Off Ver
    Excel 2003 - ENGLISH version
    Posts
    46

    Strange Boolean If function result

    Hola,
    A stepped over a very strange situation (for me) while using the "" value in order to leave a cell empty if the condition is True.
    Assume A1 has 123 and B1 has: =IF(A1<100 then "smaller","").
    The above formula returns an empty cell.
    So far so good.
    When I type, in C1: =IF(B1>321,"X","") it returns, to my surprise, X.
    My logic, which is probably different from the Excels, says C1 should remain empty - because "" equals zero.
    I tried to check: =CODE(B1) which returns: #VALUE!
    >Doesn't "" has an ASCII Code?
    >Doesn't it Equal zero?
    >Does it equal to NULL? and if so can I check something against NULL?
    Where am I wrong ?
    Thanks, Al
    Last edited by alfredkri; 01-02-2011 at 04:51 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    16,058

    Re: Strange Boolean If function result

    It consider text greater than number so you get that "" is greater than 123
    Never use Merged Cells in Excel

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Strange Boolean If function result

    Believe it or not, text strings (including the NULL text string "") are all greater than any number.

    Your C1 formula should test the value of A1 I'd suggest.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

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

    Re: Strange Boolean If function result

    Alternatively, using the example (and ignoring the fact your first formula B1 implies all results shall be text), you can test the numeric value of B1 either via N(B1) or SUM(B1)

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    11-27-2010
    Location
    Madrid, Spain
    MS-Off Ver
    Excel 2003 - ENGLISH version
    Posts
    46

    Re: Strange Boolean If function result

    Thanks to you all.
    Al

+ 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