Forum Discussion
Opposite duplicate column
Is there a formula that can highlight duplicate teams? Here is the situation. I asked for everyone to submit teams. I noticed that some employee #2 was already submitted by employee #1. How would I highlight the duplicate team? See the below for sample of teams.
| Team | Employee 1 | Employee 2 |
| 1 | Yvonne | Bob |
| 2 | Yvonne | Jane |
| 3 | Yvonne | John |
| 4 | Jane | Bob |
| 5 | John | Bob |
| 6 | Bob | Yvonne |
| 7 | Bob | Jane |
| 8 | Jane | John |
| 9 | John | Yvonne |
| 10 | Bob | John |
4 Replies
- Patrick2788Silver Contributor
One approach is to identify the duplicate teams with conditional formatting. Since conditional formatting is a legacy feature (and doesn't play well with arrays), we must keep it simple:
Conditional formatting formula:
=COUNTIFS(Employee_1,$F2,Employee_2,$G2)+COUNTIFS(Employee_2,$F2,Employee_1,$G2)>1 - djclementsSilver Contributor
Yvonne2000 With Excel for MS365, there's probably a number of ways to find the duplicates regardless of column order. Here's a few options:
First, you could try to use Conditional Formatting to highlight any team combinations that appear more than once in the list using the ROWS function with FILTER:
=ROWS(FILTER($A$2:$A$11,(($B$2:$B$11=$B2)*($C$2:$C$11=$C2))+(($B$2:$B$11=$C2)*($C$2:$C$11=$B2))))>1However, this method may not help very much, especially if there are more duplicates than not. As you can see in the screenshot below, the majority of the rows are highlighted, so it does very little to identify which rows are duplicates of each other...
Another option would be to use the BYROW function to SORT each row by columns, then use the UNIQUE function to return the unique list of teams. Since nested arrays are not supported, TEXTJOIN, TEXTBEFORE, TEXTAFTER and HSTACK are also required to make this work:
=LET( arr, BYROW(B2:C11, LAMBDA(r, TEXTJOIN(",", FALSE, SORT(r,,, TRUE)))), UNIQUE(HSTACK(TEXTBEFORE(arr, ","), TEXTAFTER(arr, ","))))UNIQUE Team Combinations
While this method works great for providing a unique list, it still doesn't identify exactly which team numbers were duplicates of each other. The last method I'll offer is to use the XMATCH function to identify the "first match" where each team was found in the list, then use the SORTBY function to sort the results:
=LET( arr, A2:C11, _c1, INDEX(arr,,2), _c2, INDEX(arr,,3), FindFirst, BYROW(arr, LAMBDA(r, LET( _e1, INDEX(r,2), _e2, INDEX(r,3), XMATCH(1, ((_c1=_e1)*(_c2=_e2))+((_c1=_e2)*(_c2=_e1)))))), SORTBY(HSTACK(arr, FindFirst), FindFirst))SORTBY Duplicate Team Combinations
As shown in the screenshot above, this method groups the duplicate teams together, so it's easy to spot the duplicates. Cheers!
- Harun24HRBronze ContributorFrom your given example which cells will bi highlighted?
- Yvonne2000Copper ContributorThe duplicate teams. For example, Team #1 and #6 are the same team.