Conditional formatting to change font color when value changes, allow sorting

skyshow1

New Member
Joined
Mar 6, 2009
Messages
18
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet where I want to track if a value is changed (versus a baseline, or "original value") by changing its font color to red. To accomplish this I have copied the original data to a second sheet which I have hidden. I am using conditional formatting on the first sheet utilizing "Use a formula to determine which cells to format." The formula I am using is very simple; it just compares the values from the first sheet to the values in the second sheet, e.g. "=B2<>Sheet2!B2." Note in the example here the values in Column A cannot be changed; I only need to track changes in the numerical values.
Conditional Test.xlsx
ABCDE
1DirectionCol1Col2Col3Col4
2North1234
3South2345
4East3456
5West4567
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:E5Expression=B2<>OrigValues!B2textNO

Conditional Test.xlsx
ABCDE
1DirectionCol1Col2Col3Col4
2North1234
3South2345
4East3456
5West4567
OrigValues

This is all well and good, until the first table is sorted (e.g., largest to smallest), resulting in every value turning red. Essentially the references in the conditional formatting formulas don't "move" along with the rows. Sorted table:
Conditional Test.xlsx
ABCDE
1DirectionCol1Col2Col3Col4
2West4567
3East3456
4South2345
5North1234
Sheet1

In summary I would like the cell references in the conditional formatting to remain pointing to the original values on sheet OrigValues, even while being sorted. I have tried using various combinations of relative vs. absolute references, including putting a separate conditional formatting condition for each row (see below for what I thought was a promising approach to solve this!), but just can't seem to get it to work properly.
Conditional Test.xlsx
ABCDE
1DirectionCol1Col2Col3Col4
2North1234
3South2345
4East3456
5West4567
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B5:E5Expression=B5<>OrigValues!B$5textNO
B4:E4Expression=B4<>OrigValues!B$4textNO
B3:E3Expression=B3<>OrigValues!B$3textNO
B2:E2Expression=B2<>OrigValues!B$2textNO

Any ideas on how to accomplish this? Thanks in advance for your help!
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Welcome to the Board.

Let me ask you if you change the value from the original does it turn red? and if you change it back to the original does it change back to black?
and are you sorting the "hidden" data as well so that the values are sorted as well?
 
Upvote 0
See if this CF works for you.

skyshow1.xlsm
ABCDE
1DirectionCol1Col2Col3Col4
2North1234
3South2345
4East3456
5West4567
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:E5Expression=B2<>XLOOKUP($A2,'Original Values'!$A$2:$A$5,'Original Values'!B$2:B$5)textNO


Now sort (still no red since values have not changed)

skyshow1.xlsm
ABCDE
1DirectionCol1Col2Col3Col4
2West4567
3East3456
4South2345
5North1234
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:E5Expression=B2<>XLOOKUP($A2,'Original Values'!$A$2:$A$5,'Original Values'!B$2:B$5)textNO


Now change a couple of the values (the changed values show up red)

skyshow1.xlsm
ABCDE
1DirectionCol1Col2Col3Col4
2West4567
3East7456
4South23xxx5
5North1234
Sheet1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:E5Expression=B2<>XLOOKUP($A2,'Original Values'!$A$2:$A$5,'Original Values'!B$2:B$5)textNO
 
Upvote 0
Solution
Welcome to the Board.

Let me ask you if you change the value from the original does it turn red? and if you change it back to the original does it change back to black?
and are you sorting the "hidden" data as well so that the values are sorted as well?
Yes, on Sheet1 any values that are changed do properly turn red, and back to black if changed back to the original values. It is not possible to sort the "hidden" data - it must remain fixed. The only problem I have is when the values are sorted on the visible sheet.
 
Upvote 0
See if this CF works for you.
YES! Sorry, I got tied-up in meetings and wanted to test this before I replied. Thanks for the suggestion! The lesson learned for me is that conditional formatting formulas will not move with sorting, unlike other cell formatting such as the cell interior color or font type. I had not considered doing a VLOOKUP- great idea! I wish there were a simpler solution but it seems the only way to do this if I want to keep the original values on a separate sheet (without VBA). I'll mark your solution as the accepted one. Thanks again!
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
Members
453,021
Latest member
Justyna P

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