+ Reply to Thread
Results 1 to 9 of 9

Excel IF statement fails when using =

  1. #1
    Registered User
    Join Date
    12-18-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    5

    Excel IF statement fails when using =

    I came over this strange problem i cant seem to figure out.

    32 32,2 =ABS(B6-C6) =D6 0,2 =IF(E6<=F6;"OK";"Fault")

    32,00 32,20 0,2 0,2 0,2 Fault

    Formula clearly states that if 0,2<=0,2 then OK but it calculates as Fault instead???
    if i just write the number 0,2 instead of either =ABS(B6-C6) or =D6 the logic <= in the if statement computes correctly and shows OK.

    I have checked the formatting of the cells and all cells registers as numbers.
    The really strange part is this: this fault does not occur for numbers that are less then 32, I have tested several combinations like 30 30,2 where the difference is exactly the same with the identical difference but it shows up as OK.

    When the numbers are 31,9 32,1 with the difference 0,2 it fails, and so does it fail for all numbers larger than 32 with difference 0,2 but it is OK for all numbers less than 32 with difference 0,2.

    I need help seeing the logic here.... Any ideas on what i am overlooking?

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Excel IF statement fails when using =

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? However, please give us an indication of the approximate number of rows of data you want the solution to work with (100, 1000, 100,000 or whatever). Please don't attach a picture of an Excel sheet (no-one will want to re-type all your stuff before starting).

    1. It does NOT have to be your real sheet - mock up a SAMPLE if you need to. But not 1000's of rows!!! It makes manual checking so tedious. Whatever you do... make sure that all confidential information is removed first!!

    2. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    3. Make sure that your desired solution is also shown (mock up the results manually).

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,770

    Re: Excel IF statement fails when using =

    It'a probably a floating point error. Attach a sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Registered User
    Join Date
    12-18-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    5

    Re: Excel IF statement fails when using =

    Cut out and added a small list where the strange fault is present.

    currently using Norwegian version so "IF" may show as "HVIS" but I believe it will change dependent on the language pack.
    Attached Files Attached Files

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,770

    Re: Excel IF statement fails when using =

    As I suspected, it's a floating point error:

    Excel 2016 (Windows) 32 bit
    E
    10
    0.2000000000000030000000
    Sheet: Ark1

    Change the formula to this:

    =ROUND(ABS(C6-D6),1)

    Adjust for your locale.

  6. #6
    Registered User
    Join Date
    12-18-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    5

    Re: Excel IF statement fails when using =

    Why does this floating error occur?

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,770

    Re: Excel IF statement fails when using =

    A 'thank you' would be nice!

    It's well-documented. Read all about it here: https://www.microsoft.com/en-us/micr...wrong-answers/

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  8. #8
    Registered User
    Join Date
    12-18-2014
    Location
    Norway
    MS-Off Ver
    2013
    Posts
    5

    Re: Excel IF statement fails when using =

    Oops Sorry,

    Thank you very much. Its always good to learn new things

    I am a little distracted by various tasks going on simultaneously today so I will have to excuse myself by that

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,770

    Re: Excel IF statement fails when using =

    OK - we'll let you off - this time.

    Please don't forget to mark the thread as solved.

+ 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. Why and If statement works in Excel 2007 but fails to work in Excel 2010?
    By Superfly1984 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-03-2013, 08:26 AM
  2. Replies: 0
    Last Post: 02-06-2013, 09:13 PM
  3. Validation list from Mac Excel 2011 fails to function on Windows 7 Excel 2010
    By lhlevasseur in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 12-17-2012, 07:08 PM
  4. Replies: 3
    Last Post: 10-23-2012, 07:50 AM
  5. Database Query macro works in Excel 2003 but fails in Excel 2007
    By NBVC in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-11-2012, 12:24 PM
  6. If statement fails?
    By Rick_Stanich in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-02-2010, 10:05 AM
  7. Script fails in Excel was okay before.
    By Jonah in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 03-05-2006, 05:30 PM
  8. [SOLVED] Excel fails to save
    By ChrisH in forum Excel General
    Replies: 3
    Last Post: 01-06-2006, 09:35 AM

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