If the difference is more then 5% then make the cell red

Romano_odK

Active Member
Joined
Jun 4, 2020
Messages
379
Office Version
  1. 365
Platform
  1. Windows
Good morning,
In my case the cell H27 and H28 have to values, numbers. I need the cell to go red if there is a difference of more then 5% between them. The sheet will be refresh because it has connections to the SQL server so every time after a refresh this needs to look at this statement again. How can I achieve this?

Thank you for your time.

Romano
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
if the sheet is refreshing then standard conditional formatting - should work

do you want the difference based on H27 or on H28

=(H27-H28)/H28 - OR =(H27-H28)/H27

then add to conditional formatting
=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)

EXCEL FORUM.xlsx
H
271
281.04
Sheet3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H27:H28Expression=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)textNO


=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)

for 2007, 2010 , 2013 , 2016 , 2019 or 365 Subscription excel version
Conditional Formatting

Highlight applicable range >>
H27:H28 - Change, reduce or extend the rows to meet your data range of rows

Home Tab >> Styles >> Conditional Formatting
New Rule >> Use a formula to determine which cells to format
Edit the Rule Description: Format values where this formula is true:
=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)

Format [Number, Font, Border, Fill]
choose the format you would like to apply when the condition is true
OK >> OK

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Upvote 0
if the sheet is refreshing then standard conditional formatting - should work

do you want the difference based on H27 or on H28

=(H27-H28)/H28 - OR =(H27-H28)/H27

then add to conditional formatting
=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)

EXCEL FORUM.xlsx
H
271
281.04
Sheet3
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H27:H28Expression=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)textNO


=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)

for 2007, 2010 , 2013 , 2016 , 2019 or 365 Subscription excel version
Conditional Formatting

Highlight applicable range >>
H27:H28 - Change, reduce or extend the rows to meet your data range of rows

Home Tab >> Styles >> Conditional Formatting
New Rule >> Use a formula to determine which cells to format
Edit the Rule Description: Format values where this formula is true:
=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)

Format [Number, Font, Border, Fill]
choose the format you would like to apply when the condition is true
OK >> OK

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
Good moring,

First of all thank you for your explanation. I understand what you are telling me. Now I have tested this but for some reason the cells are highlighted right away and there is no 5% difference between them. It seems to work the other way around, now when its less then the formula works. Maybe I am doing something wrong here.
Have a nice day.
 
Upvote 0
yes sorry , i used
=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)
which is highlighting anything thats greater then 5% or less than -5% dah!!!!!
sorry
change to
=AND((($H$27-$H$28)/$H$28)>=0.05,(($H$27-$H$28)/$H$28)<=-0.05)
 
Upvote 0
Solution
yes sorry , i used
=AND((($H$27-$H$28)/$H$28)<=0.05,(($H$27-$H$28)/$H$28)>=-0.05)
which is highlighting anything thats greater then 5% or less than -5% dah!!!!!
sorry
change to
=AND((($H$27-$H$28)/$H$28)>=0.05,(($H$27-$H$28)/$H$28)<=-0.05)
It works, thank you again for your help and have a great day.
 
Upvote 0

Forum statistics

Threads
1,215,580
Messages
6,125,654
Members
449,245
Latest member
PatrickL

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