How do I highlight a cell in Excel where the value is different to the cell five cells below it - and apply this to a whole row?

Posted on 2016-09-15
Last Modified: 2016-09-17
I've been trying to get to grips with conditional formatting but I've not managed to get Excel to do what I want.

I have a row of data - row 2 - and I want to compare each value in row 2 with the data in the same column in in row 7.

If the data is different I want the cell to be highlighted in a colour.

I'm on Excel 2016.
Question by:purplesoup
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
LVL 26

Expert Comment

by:Shaun Kline
ID: 41800148
Select the rows to which you want to apply conditional formatting.

Create a new conditional rule using the "Use a formula to determine cells to format" option.

In the "Format Values where this formula is true:", you can use a formula like:
=OR($A2<>$A7, $B2<>$B7....)
The comparison should be repeated for each column you want to compare.

Another option is to use:
($I should be your end column letter.)

Author Comment

ID: 41801508
I tried the first option - which obviously takes along time to type in all the columns - I have about 100 - but it just highlights all the cells of both rows, even though I can see only about 3-4 are different.

Author Comment

ID: 41801510
Second option does the same thing...
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.


Author Comment

ID: 41801519
What it is doing is highlighting the whole row if any values are different instead of just highlighting the cells that are different.
LVL 26

Expert Comment

by:Shaun Kline
ID: 41801525
Thought you wanted to know which rows had different values. My mistake. To highlight just the cells with differences (cells in row 2 that are different than a cell in the same column 5 rows below it), use:

=AND($A7<>"", A2<>A7)

This formula assumes that column A will always have a value ($A7 <> ""), and prevents comparing a row against one that is completely blank. If that is not the case, and you do not have a column that will always have a value, let me know and I can provide a different formula.

Author Comment

ID: 41801802
I may be missing something here. I highlighted A2 and A7 and entered the formula above - the values were different and it correctly highlighted both cells.

I then highlighted B2, C2 and D2, and B7, C7 and D7 and entered the following (none of them had blank values):

=AND($B2<>$B7, $C2<>$C7,$D2<>$D7)

Although all the values matched, it highlighted B2, C2 and D2.

I then highlighted B2 and B7 - as I said the values match - and entered this formula.

=AND($B7<>"", B2<>B7)

This worked - there is no highlighting.

I then highlighted C2, D2 and E2 and C7, D7 and E7 and entered the following formula:

=AND($C7<>"", C2<>C7,$D7<>"",D2<>D7,$E7<>"",E2<>E7)

Again, this highlighted C2, D2 and E2 even though the values matched.

So while I can see that this formula works if I apply it one cell at a time, I can't go through 100 of cells in a row and apply the formatting individually to each one. I need something which just says compare these two rows and highlight the cells that are different. Is this possible?

Author Comment

ID: 41801804
Thank you for your suggestions by the way I don't mean to be rude.
LVL 26

Accepted Solution

Shaun Kline earned 500 total points
ID: 41801861
I'm listing the steps you need to follow to make this work. I believe you are missing the first step.

1.) Highlighting the entire area on your spreadsheet where you want to compare cells. If you are doing columns A to H and rows 2 to 20, then select the area from A2 to H20.
2.) Then select Conditional Formatting and then New Rule.
3.) Select "Use a formula to determine which cells to format".
4.) Enter the formula you want to use. In this case, try:
=AND($A7<>"", A2<>A7)
5.) Select your formatting.
6.) Click OK to exit the dialog box.

The use of the $ in the formula anchors that portion of the formula to column A, while the rest of the formula is not anchored. So if there is a difference between cells B2 & B7, the conditional formatting rule treats the formula as if it was =AND($A7<>"", B2<>B7).

Oh, and you are not being rude. Conditional formatting beyond some of the simple stuff can be very confusing until you work through it. Sometimes it helps to break out what you are attempting into small steps, and adding on more complex parts until you get the desired result.

Author Comment

ID: 41803118

Thank you for your patience - I've attached screenshots to show it working.

Step 1Step 2Step 3

Author Closing Comment

ID: 41803119
I'm very happy :)
LVL 26

Expert Comment

by:Shaun Kline
ID: 41803391
Glad to hear it worked and glad to help.

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question