Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


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
Medium Priority
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 27

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...
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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 27

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 27

Accepted Solution

Shaun Kline earned 2000 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 27

Expert Comment

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

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
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…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

721 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