# Conditional Formatting shows wrong color!

#### brncao

##### Board Regular
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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Are A & B numbers or text?

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?

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.

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

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.

Replies
22
Views
707
Replies
1
Views
278
Replies
1
Views
323
Replies
1
Views
710
Replies
3
Views
324

1,203,075
Messages
6,053,390
Members
444,661
Latest member
liamoohay

### 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.

### Which adblocker are you using?

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

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