Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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
11
Medium Priority
?
76 Views
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.
0
Comment
Question by:purplesoup
  • 7
  • 4
11 Comments
 
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:
= CONCATENATE($A2:$I2)<>CONCATENATE($A7:$I7)
($I should be your end column letter.)
1
 

Author Comment

by:purplesoup
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.
0
 

Author Comment

by:purplesoup
ID: 41801510
Second option does the same thing...
0
Industry Leaders: 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

by:purplesoup
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.
0
 
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.
1
 

Author Comment

by:purplesoup
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?
0
 

Author Comment

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

Accepted Solution

by:
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.
1
 

Author Comment

by:purplesoup
ID: 41803118
EXCELLENT!

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

Thanks!
Step 1Step 2Step 3
0
 

Author Closing Comment

by:purplesoup
ID: 41803119
I'm very happy :)
0
 
LVL 27

Expert Comment

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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
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.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

886 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