Compare cell values in Column based on cell values in adjacent column

harrysolomon

New Member
Joined
Mar 6, 2002
Messages
25
I need to do a comparison of values in one column on a worksheet based on the values in an adjacent column of the same worksheet. The specific scenario is as follows.

The code should compare the values in Column B, based on the corresponding values listed in Column A. Discrepancies in the Column B values should be highlighted.

In this example, the value XXX appears in Column A in Rows 2 - 4, meaning the corresponding values in Column B on Rows 2 - 4 should be compared to each other to find the non-matching value and as a result Red (B4) should be highlighted.

Then for Rows 5 - 6 where YYY appears in Column A, the corresponding values in Rows 5 - 6 in Column B should be compared to each other. In this case no discrepancy will be found so nothing should happen in Rows 5 - 6 in Column B.

And then the same thing for Rows 7 - 9 with the ZZZ value and the corresponding values in Column B Rows 7 - 9. The value Orange (B7) should be highlighted after B7 – B9 are compared to each other.

Thanks in advance for any help with this issue.
harrysolomon

Sample workbook.xls
AB
1Column AColumn B
2XXXGreen
3XXXGreen
4XXXRed
5YYYBlue
6YYYBlue
7ZZZOrange
8ZZZYellow
9ZZZYellow
Sheet1
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi,

Based on your sample and description, use this formula for Conditional Formatting:

Book3.xlsx
ABC
1Column AColumn B
2XXXGreenFALSE
3XXXGreenFALSE
4XXXRedTRUE
5YYYBlueFALSE
6YYYBlueFALSE
7ZZZOrangeTRUE
8ZZZYellowFALSE
9ZZZYellowFALSE
10AAAWhiteFALSE
Sheet732
Cell Formulas
RangeFormula
C2:C10C2=AND(COUNTIF(A$2:A$10,A2)>1,COUNTIFS(A$2:A$10,A2,B$2:B$10,B2)=1)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B10Expression=AND(COUNTIF(A$2:A$10,A2)>1,COUNTIFS(A$2:A$10,A2,B$2:B$10,B2)=1)textNO
 
Upvote 0
Solution
Your welcome, thanks for the feedback.
Actually, they are the Exact same formula, I just show it as CF to show the highlight, and as Formula in column C to show the Logical results.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,869
Members
449,054
Latest member
juliecooper255

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