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

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 758
  • Last Modified:

Conditional formatting to highlight differences between two worksheets

Hey guys,

I have been driving myself crazy trying to find the answer to this problem.

I have two contact lists, each in their own worksheet in an Excel 2010 workbook.

I need to find if any contact names in contact list B match those in contact list A. And if the name matches I need to check if the rest of their details are the same. If they dont match, I would like to use conditional formatting to highlight the cells that are different in contact list A.

I then also need to do the opposite, compare list A to B and highlight the unique contact names.

I spent a large part of yesterday trying to figure this out with no success. What I think I just figured out this morning was that using the VLOOKUP formula to return the matching text from the other worksheet, the conditional format doesn't seem to be able to recognise when the text matches and hence format the cell appropriately.

I would really appreciate any assistance that anyone may have. My brain turned to mush yesterday. Thanks.
0
defecta
Asked:
defecta
  • 5
  • 3
2 Solutions
 
byundtCommented:
Here are two Conditional Formatting formulas to consider. The first one highlights non-matching detail info in column B, while the second one highlights unique names.
=INDEX(Sheet1!B:B,MATCH($A1,Sheet1!$A:$A,0))<>B1
=COUNTIF(Sheet2!$A:$A,$A1)=0
0
 
defectaAuthor Commented:
Thanks byundt.

I think I am applying the first formula incorrectly. Here is what I am trying to do.

I am applying that first conditional format formula to cell A1 on Sheet1.
I want it to find if A1 on Sheet 1 is unique in column C on Sheet2.
So the formula should look this?
=INDEX(Sheet2!C:C,MATCH($A1,Sheet1$A:$A,0))<>C1

(I dont understand how that B1 operates)

Thanks.
0
 
defectaAuthor Commented:
I have the second formula working perfectly, thank you byundt.

I am still stuck with the first though.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
byundtCommented:
I've posted a sample file showing my suggested Conditional Formatting formulas in action.

My first Conditional Formatting formula was intended to be used on Sheet2. If you are using it on Sheet1, then it should be:
=INDEX(Sheet2!C:C,MATCH($A1,Sheet2$A:$A,0))<>C1

Brad
ConditionalFormattingQ28158812.xlsx
0
 
defectaAuthor Commented:
That is excellent, Thank you so much byndt!

I think I can take it from here.
0
 
defectaAuthor Commented:
One last query.

Can you explain what function the C1 has at the end of that formula?
0
 
byundtCommented:
=INDEX(Sheet2!C:C,MATCH($A1,Sheet2$A:$A,0))<>C1

In the above formula, MATCH is looking at Sheet2 column A and returning the index number (equivalent to a row number in this case) for where the value in Sheet1 cell A1 might be found.

The INDEX function then looks at Sheet2 column C on the same row, and returns a value.

The <>C1 part of the formula then compares the value from the INDEX to the contents of cell C1. If they are different (the <> part of the expression), then the formula returns TRUE. If they are the same, then the formula returns FALSE.

Conditional Formatting is expecting either a TRUE or FALSE value. If it gets anything other than TRUE, the Conditional Formatting doesn't occur. For example, if the MATCH fails (because the value in Sheet1 cell A1 isn't found in Sheet2 column A), the formula returns a #N/A error value--and Conditional Formatting doesn't occur. Only if there is a match in column A and the value in column C differs does the formula return TRUE--and the Conditional Formatting then highlights that cell.

I was careful to use $ in the formula so you could copy it down and across and the Conditional Formatting would be applied as required. The $ means to keep the reference to column A fixed, both for Sheet1 cell A1 and Sheet2 column A.

The references to row 1 and column C are relative. Assuming that they are correct for the top left cell in the range being Conditional Formatted, then those references will automatically adjust row number and column letter as required for all other cells that receive that formatting.

Brad
0
 
defectaAuthor Commented:
Excellent explanation and my discovery this morning was leading me to that conclusion. That conditional formatting needs a true or false value. (I should have RTFM! LOL!)

Thanks again for a prompt and excellent explanation of how this all works.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now