Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

compare to cell values

Status
Not open for further replies.

ridhirao22

Programmer
Aug 27, 2010
140
US
Hi,

Using Excel 2003.

I have file where I am trying to compare the cells values as

= A1=B1 in Cell C1 and get results as below, even though both the cells are same and matching How can I get either true or 0 when the cells match?

For eaxmaple
A B C
0.0011 0.0011 true
(0.0026) (0.0026) false
(0.0021) (0.0021) false
0.0001 0.0001 true

Any help is appreciated.

TIA,
RR



 
I think I figure by rounding the cell values.

Thanks!
 



Hi,

Comparing decimal values can be tricky. Normally this would work...
[tt]
=A1=B1
[/tt]


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
[ ]
Why are you trying to get a false when both cells are negative?

=A1=B1 will not give you a false when both cells are negative and equal.

mmerlinn


Poor people do not hire employees. If you soak the rich, who are you going to work for?

"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Raymond
 
even though both the cells are same and matching How can I get either true or 0 when the cells match?
The OP said NOTHING about how negative values act any different.

If you think that parentheses MAKE a value negative, you are mistaken. Parentheses or red shading CAN indicate a negative number, but that condition is merely a DISPLAY FORMAT.

So if the requirement is for negative values to have a different specification, then it ought to be explicitly and clearly stated, in which case a solution could be...
[tt]
=AND(A1=B1,ABS(A1)=A1)
[/tt]


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
and if you do run into the problems of comparing decimals in the presence of rounding errors, try
=if(abs(A1-B1)<TinyValue, TrueResult, FalseResult)
where TinyValue is a number that is much smaller than is relevant to you, but larger than rounding errors.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top