Conditional Formatting shows wrong color!

brncao

Board Regular
Joined
Apr 28, 2015
Messages
139
It worked previously, but all of a sudden it's showing the wrong color. Before you ask, there are no percentages and fractions. Just additions and subtractions of cash. I'm trying to do this: if A = B, shade with light green fill with dark green text; if A <> B, shade with light red fill with dark red text.

But... when A = B, I'm getting a light red fill and dark red text. Why? A <> B works fine.

I'm just staring at the Conditional Formatting Rules Manager and can't wrap my mind around this.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,432
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Are A & B numbers or text?
 

brncao

Board Regular
Joined
Apr 28, 2015
Messages
139
They're numbers.

I found the culprit. The calculated cell is, in reality, $71,571.0799999998, which is not equal to $71,571.08. What the hell? There's only two decimal places and I'm just doing basic adding and subtracting. What's going on?
 

brncao

Board Regular
Joined
Apr 28, 2015
Messages
139
They're numbers.

I found the culprit. The calculated cell is, in reality, $71,571.0799999998, which is not equal to $71,571.08. What the hell? There's only two decimal places and I'm just doing basic adding and subtracting. What's going on?
71123.13
1445000
1444552.05
=A1+A2-A3

<tbody>
</tbody>
Remember to increase decimal places.
 

deletedalien

Well-known Member
Joined
Dec 8, 2008
Messages
505
Office Version
  1. 2013
Platform
  1. Windows
Whenever i do conditional formatting i usually avoid this by "locking" the ranges say for example you are doing 1 criteria 0-10 and second criteria 11-20 and a third one 21 and over

i do between 0 to 10.0000001

then between 11 to 20.0000001

then lastly

between 21 - 1000000000000


or something along those lines depending on the scnenario

Juuuuuust to make sure
 

JoeMo

MrExcel MVP
Joined
May 26, 2009
Messages
17,432
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
They're numbers.

I found the culprit. The calculated cell is, in reality, $71,571.0799999998, which is not equal to $71,571.08. What the hell? There's only two decimal places and I'm just doing basic adding and subtracting. What's going on?
As you have discovered, Excel has 15-digit precision so when comparing number A to number B even though they may appear to be equal when viewing the cells they are in, if they are not equal out to the limit of Excel's precision then A=B is false. Better to use something like Round(A,2) = Round(B,2) to handle CF for number comparisons.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,045
Messages
5,639,743
Members
417,108
Latest member
Thein Than

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
Top