Change background colour of a cell if value is + or - value of another cell

julhs

Active Member
Joined
Dec 3, 2018
Messages
407
Office Version
  1. 2010
Platform
  1. Windows
I want to change cell background colour of ANY cell in D5:D15 that is within + or - .05 of B5

B5 = 2.5 (is the reference cell)
D5:D15 = values that change dependent on another cell

In this example,
B5 = 2.5
D11 = 2.52,

So B5+0.05 = 2.55, D11= 2.52 so is below 2.55, so background colour is changed to green
and if the reverse, B5-0.05 = 2.45, D10 = 2.47, so it is above 2.45 then background colour is changed to orange

Col F is some testing of formula as a potential helper column for Condition Formating to use


Book1.xlsm
ABCDEFG
1
2
3QuantityVariable values
4
52.51.44below
61.62below
71.81below
82.16below
92.34below
102.47tt
112.52tt
122.71above
132.88above
143.06above
153.24above
16
Sheet1
Cell Formulas
RangeFormula
F5:F15F5=IF(D5>($B$5+0.05),"above",IF(D5<($B$5-0.05),"below","tt"))
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You can use Conditional Formatting, using two rules:

First rule:
1. Select cells D5:D15
2. Go to Conditional Formatting and choose the formula option (last one)
3. Enter this formula:
Excel Formula:
AND(($D5-$B$5)>0,($D5-$B$5)<.05)
4. Choose the green formatting color

Second rule:
1. Select cells D5:D15
2. Go to Conditional Formatting and choose the formula option (last one)
3. Enter this formula:
Excel Formula:
AND(($B$5-$D5)>0,($B$5-$D5)<.05)
4. Choose the orange formatting color
 
Upvote 0
Solution
That works a treat.!

No way I was going to stumble my way through testing to come up with that as I have done in the past, hence the post!

Couple of somewhat related Condition Formatting questions.
Why when I write a New Condition, done all the necessary stuff, that sometimes the formula appears in the rules with “” around it?

Other is; I’ve noticed that in numerous threads regarding Condition Formatting the “Stop if True” had NOT been ticked. I thought if you didn’t that Condition Formatting was constantly hunting eating up processor resources?
 
Upvote 0
Why when I write a New Condition, done all the necessary stuff, that sometimes the formula appears in the rules with “” around it?
I have not really seen that. I suppose that could happen if you do not start your formula with an equal sign (=).

Other is; I’ve noticed that in numerous threads regarding Condition Formatting the “Stop if True” had NOT been ticked. I thought if you didn’t that Condition Formatting was constantly hunting eating up processor resources?
It certainly would be more efficient if you did check that box. I confess, I seldom do myself, and rarely have performance issues.
I suppose if you had a huge amount of data and/or a lot of rules, it could make a difference.
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

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