Is there a way to highlight duplicates in two columns?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,687
Office Version
  1. 365
Platform
  1. Windows
The built-in highlighting function for duplicates is very handy. But I can only get it to work on one table column. Is there a way to get it to treat 2 columns as if they were one?

In the tables below, it worked on the state columns. For the table on the left, I selected both name columns then added the highlighting. But it applies to each column separately. For the table on the right, I manually highlighted the cells that are duplicates in both name cells. That is how I would like it to work in the table the left. Is there any way to make that happen?

Conditional Highlighting.xlsx
CDEFGHI
5StateFirst NameLast NameStateFirst NameLast Name
6CaliforniaAnselAdamsCaliforniaAnselAdams
7UtahButchCassidyUtahButchCassidy
8VermontBernieSandersVermontBernieSanders
9MaineStephenKingMaineStephenKing
10ChicagoMichaelJordanChicagoMichaelJordan
11AlabamaLionelRichieAlabamaLionelRichie
12CaliforniaJoeDiMaggioCaliforniaJoeDiMaggio
13South DakotaKristiNoemSouth DakotaKristiNoem
14NevadaMarkTwainNevadaMarkTwain
15Washington, D. C.StephenColbertWashington, D. C.StephenColbert
16DelawareJoeBidenDelawareJoeBiden
17New YorkJoeDiMaggioNew YorkJoeDiMaggio
18CaliforniaArnoldSchwarzeneggerCaliforniaArnoldSchwarzenegger
19MassachusetsJohnAdamsMassachusetsJohnAdams
20TennesseeMichaelJordanTennesseeMichaelJordan
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H17:I17Cell ValueduplicatestextNO
H12:I12Cell ValueduplicatestextNO
H20:I20Cell ValueduplicatestextNO
H10:I10Cell ValueduplicatestextNO
G20Cell ValueduplicatestextNO
G10Cell ValueduplicatestextNO
C6:C20Cell ValueduplicatestextNO
D6:E20Cell ValueduplicatestextNO
G6:G9,G11:G19Cell ValueduplicatestextNO
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You can, but you need a custom rule:

Book1
CDE
5StateFirst NameLast Name
6CaliforniaAnselAdams
7UtahButchCassidy
8VermontBernieSanders
9MaineStephenKing
10ChicagoMichaelJordan
11AlabamaLionelRichie
12CaliforniaJoeDiMaggio
13South DakotaKristiNoem
14NevadaMarkTwain
15Washington, D. C.StephenColbert
16DelawareJoeBiden
17New YorkJoeDiMaggio
18CaliforniaArnoldSchwarzenegger
19MassachusetsJohnAdams
20TennesseeMichaelJordan
Sheet4
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D6:E20Expression=COUNTIFS($D$6:$D$20,$D6,$E$6:$E$20,$E6)>1textNO
C6:C20Cell ValueduplicatestextNO
 
Upvote 0
Solution
I was concerned that the absolute expression you provided might not expand if rows are added to the table. I tested it and it seems to work. Is that guaranteed?

I tried an expression using table notation.

Excel Formula:
=COUNTIFS(Table13[First Name],Table13[@[First Name]],Table13[Last Name],Table13[@[Last Name]])>1

It doesn't work. Why is that?

I also noticed that Excel does not prompt with the CountIFs parameters like it does if I type the formula in a cell. That's unfortunate. I guess that was just too much trouble. 😒😡
 
Upvote 0
I noodled around a bit with this, and came up with the same results that you did. Using standard formula syntax works fine on a table, and it expands with the table. I think you can count on that. That's intentional behavior. I actually found it annoying in cases where I didn't want it to expand.

As far as using table notation, I found the same thing too, that it doesn't work in CF. The "why" I'd have to speculate on. One reason is that the @ character for "current row" wouldn't have a table/position to relate to. But even when I wrote a formula that didn't use that, it still didn't work in CF. I'd guess that either they disallowed all table syntax in CF because of the @ issue, or because both CF and tables have a way to expand, and they didn't want to worry about those systems conflicting.
 
Upvote 0
Good points and thanks for the noodling.

This whole problem could have been avoided if M$FT could bother to do things right. If I select multiple columns and then do Conditional Formatting | Highlight Cells Rules | Duplicate Values ..., it could simply ask me if I want the columns treated separately or as a group. The chances of M$FT actually taking their users seriously are less than of winning the lottery. (sigh)
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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