Conditional Formatting based on % difference

gggshk

New Member
Joined
May 28, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello, newbie here!

Can someone help me with conditional formatting e.g.

A1 has a figure of 81%
B1 has a figure of 89%

I want A1 shaded green if it's equal to or above B1.
I also want A1 shaded yellow if it's within 2% of B1 (so either 87% or 88%)
I also want A1 shaded red if it's less than the 2% threshold (e.g. 86% or less).

Thank you! :)
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
For three colors you will need three rules. However, it is not clear what you need these rules to be.

Your specification "within 2% of B1" is the range 87-91% (not either 87% or 88%).
Also "less than the 2% threshold" seems to mean the same thing but "86% or less" doesn't seem to fit any part of your description.
 
Upvote 0
Welcome to the Board!

Use these 3 Coniditional Formatting formulas in your rules:

Green:
Excel Formula:
=A1>=B1

Yellow:
Excel Formula:
=AND(A1<B1,A1>=(B1*0.98))

Red:
Excel Formula:
=A1<(B1*0.98)

Note that in your example, 87% would actually be red, as 2% less than 89% is actually 87.22%, and 87% is less than that.
You may have to round off those formulas to 2 decimal places if you want to round off to the nearest percent and make it yellow.
 
Upvote 0
you need 3 formulas in conditional formatting

I want A1 shaded green if it's equal to or above B1.
=A1 > = B1

I also want A1 shaded yellow if it's within 2% of B1 (so either 87% or 88%)
Not 2 % of the value but 2 percent absolute
=A1 > = B1 -0.02

I also want A1 shaded red if it's less than the 2% threshold (e.g. 86% or less).
=A1 < B1 -0.02

Book2
ABCDEFGHIJK
181%90%
282%90%I want A1 shaded green if it's equal to or above B1. =A1 > = B1 I also want A1 shaded yellow if it's within 2% of B1 (so either 87% or 88%) Not 2 % of the value but 2 percent absolute =A1 > = B1 -0.02 I also want A1 shaded red if it's less than the 2% threshold (e.g. 86% or less). =A1 < B1 -0.02
383%90%
484%90%
585%90%
686%90%
787%90%
888%90%
989%90%
1090%90%
1191%90%
1292%90%
1393%90%
1494%90%
1595%90%
1696%90%
1797%90%
1898%90%
1999%90%
20100%90%
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A1:B20Expression=$A1>=$B1textYES
A1:B20Expression=$A1>=$B1-0.02textYES
A1:B20Expression=$A1<$B1-0.02textYES
 
Upvote 0
Sorry i don't think i've explained it as well as i could have. If we ignore the fact that these are percentages in my cells and look at it this way.

A1 has a figure of 81
B1 has a figure of 89

If A1 was to ever change to be equal to or greater than B1 it needs to be shaded green.
If A1 was to ever change to be within 2 numbers below B1 (in this instance either 87 or 88) then it needs to shade yellow.
If A1 was to ever change to be less than 2 numbers below B1 (in this instance 86 or less) then it needs to shade red.
 
Upvote 0
Ah, I see a little difference in interpretation of your original question.

When you said 2%, I assumed you meant within 2% of the value on B1 (so a percent of a percent).
etaf interpretted as a hard-coded 2% less than the value in B1.

For example, in my interpretation, if 50% was in cell B1, 2% of 50% is 1%, so it would be looking for 49%
However, if you want to subtract a straight 2%, it would be 48%

Based on your original example, I am guessing that etaf's interpretation (and solution) may be the one you are looking for.
 
Upvote 0
as per my example
and formulas
 
Upvote 0

Forum statistics

Threads
1,214,889
Messages
6,122,097
Members
449,065
Latest member
albertocarrillom

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