+ Reply to Thread
Results 1 to 4 of 4

IF Statement Returns False When True On Certain Numbers

  1. #1
    Registered User
    Join Date
    11-26-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    8

    IF Statement Returns False When True On Certain Numbers

    First time post!

    I am subtracting one cell from another and putting the answer in a separate cell. Then using the answer in another I use a formula to see if the answer equals a certain value.

    Eg A3-A1. Answer goes in B1. Then in C1 formula IF(B1=0.2,"TRUE","FALSE")

    For some reason certain values do not work and I am completely lost for why this is happening! I use excel regularly but am no expert but this has completely stumped me. I've a horrible feeling I may look very stupid over this! Ha.

    I have attached an excel sheet in case I have not explained this very well! All three examples should show TRUE but only the last one is!!

    Thanks in advance!

    Paul
    Attached Files Attached Files

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: IF Statement Returns False When True On Certain Numbers

    Binary math strikes again...
    • Select cell A2
    • Press F2...Press F9
    The result in the formula bar will be: 0.199999999999999

    Computers work with binary representations of numbers, but humans work with decimal numbers. There are some decimal numbers that cannot be exactly represented in binary. It's the same kind of issue that prevents the fraction 1/3 from being exactly represented as a decimal number. 1/3 as a decimal is 0.333333333(ad infinitum)

    Try this:
    A3: =IF(ROUND(A2,6)=0.2,"TRUE","FALSE")

    Inelegant...but accurate.

    Does that help?
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: IF Statement Returns False When True On Certain Numbers

    It's a floating point arithmetic error.

    Change your formula in A3 to:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  4. #4
    Registered User
    Join Date
    11-26-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: IF Statement Returns False When True On Certain Numbers

    Brilliant. The ROUND seems to have fixed it! I've got a feeling I might be on here more often!

    Many thanks for the quick responses guys!!

+ 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. lookup exact match returns TRUE or FALSE
    By quade_1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2016, 02:21 AM
  2. IF STATEMENT returns False, even though the results are true
    By Biolu527 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-28-2013, 11:21 AM
  3. Replies: 5
    Last Post: 12-09-2012, 11:04 PM
  4. InStr function returns pseudo True/False?
    By GCW esq in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-04-2012, 08:00 AM
  5. [SOLVED] Function that compares dates and returns TRUE or FALSE
    By Emily in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-25-2006, 04:30 PM

Tags for this Thread

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