Unexpected result in IF

baulko

New Member
Joined
Jul 17, 2011
Messages
4
Have a very simple worksheet as follows

B C D
5 1073.41 1073.41 OK
6 =1700-626.59 1073.41 ERROR

Formula in D5

=IF((B5-C5)=0,"OK","ERROR") and similarly for row 6 using B6,C6.

Why is D6 "ERROR" ?

Using Excel 2003 SP2.
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
It does day "=(1700-626.59)" minus the quotes of course.
If B6 is treated as text we see excel #VALUE! errors as a result of trying to compare to value in C6 as requested by formula in D6.
 
Upvote 0
Thanks, I can get it to work.
The issue appeared in a home accounting sheet.
Other values appearing in the sheet seemed to be fine. This one in particular always showed ERROR.
I don't understand why but would like to be enlightened if possible.
 
Upvote 0
You're doing math on decimal values and then comparing the results. You should never do that. That's why they are not equal. Internally, the computer sees 1073.409999999 or something like that. To see if two decimal numbers are equal, you should round them first or see if the difference between them is less than, say, 0.0001, like this:

Code:
=IF((B5-C5)<0.0001,"OK", "ERROR")
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,730
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top