View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dana DeLouis Dana DeLouis is offline
external usenet poster
 
Posts: 947
Default Excel 2003 - Simple IF() Formula Will Not Work For Me

Just for discussion, I like to have a custom function that adds Financial
data as a Currency data type.
In a program such as Microsoft's Access, one usually assigns monetary values
the Currency data type also.

For your example:
=A1-Total(B1:C1)=0
returns True.

A custom function is usually more sophisticated then this one, as it will
work on multiple areas, etc.

Function Total(rng As Range)
Dim T As Currency
Dim Cell As Range

T = 0
For Each Cell In rng.Cells
T = T + Cell
Next Cell
Total = T
End Function

Again, just an idea if you want to go this route.
--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"Scott" wrote in message
...
Thanks guys. Fascinating. Us accountants cannot comprehend things that
do
not balance.

"Jerry W. Lewis" wrote:

"Scott" wrote:

All the above formulas work, but what is wrong with mine? Try mine for
yourself; there are no extra fractions past two decimal places.


=(A1-B1-C1)
evaluates to -9.09494701772928E-13, which is why your If function fails.

David's answer makes sense, but it is simple math that = zero. Why
can't
Excel do that? It seems to be a flaw to me.


As David has pointed out, all of your decimal fractions are
non-terminating
binary fractions that cannot be exactly represented in binary (just as
1/3
cannot be exactly represented as a decimal fraction). Excel (and almost
all
other computer software) uses IEEE double precision binary representation
of
floating point numbers. The decimal equivalents of the binary
approximations
to your numbers are

11813.2099999999991268850862979888916015625
5375.649999999999636202119290828704833984375
6437.5600000000004001776687800884246826171875

Do the math yourself; Excel's answer is the correct result given the
unavoidable approximations to your initial numbers.

The reason that rounding solves the problem should be obvious. The
alternate proposal of =IF(A1-SUM(B1:C1)=0,"OK","OFF") is a less robust
solution that will not work for all numbers.

Jerry