Highlight Duplicates Not Next To Each Other Using Conditional Formatting

旧巷老猫 提交于 2020-01-07 03:21:51

问题


We have a list of parts in Excel in a certain order. For reasons I won't get into, we need to highlight when there are duplicates that aren't next to each other. Currently, I'm using this formula in a conditional format to do the job.

=AND(COUNTIF($A$2:$A$82,$A2)>1,$A1<>$A2,$A2<>$A3)

This mostly works well except in cases where there are pairs of duplicates like in the example below, we would want FO-1694 to be highlighted, because they aren't all next to each other. But we would not want NIS0257 to be highlighted because they are.

Currently

Ideally, this is what we want to see...

Expected

Any ideas on this could be achieved using conditional formatting?

Note: I have directly posted this from a past post on the SuperUser Forum (Link) as I am in need of this EXACT conditional formatting for the EXACT same circumstances. I do not take credit for the construction of this post, but only hope to obtain an answer for a question that previously went unanswered.


回答1:


Use this formula:

=NOT(AND(A2=OFFSET(A2,COUNTIF($A2:$A$82,A2)-1,0),A2=OFFSET(A2,-(COUNTIF($A$2:$A2,A2)-1),0)))

If changing the range then make sure to pay attention to what is marked as absolute and relative.



来源:https://stackoverflow.com/questions/35098014/highlight-duplicates-not-next-to-each-other-using-conditional-formatting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!