title: Highlight Duplicates Not Next To Each Other Using Conditional Formatting
body: <p>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.</p>
  
  <p><code>=AND(COUNTIF($A$2:$A$82,$A2)>1,$A1&lt;>$A2,$A2&lt;>$A3)</code></p>
  
  <p>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.</p>
  
  <p>Currently<br>
  <img src="https://i.stack.imgur.com/iRlCY.png" alt="Current"></p>
  
  <p>Ideally, this is what we want to see...</p>
  
  <p>Expected<br>
  <img src="https://i.stack.imgur.com/hf14f.png" alt="Expected"></p>
  
  <p>Any ideas on this could be achieved using conditional formatting?</p>
  
  <p><sub>Note: I have directly posted this from a past post on the SuperUser Forum (<a href="https://superuser.com/questions/826257/highlight-duplicates-not-next-to-each-other-using-conditional-formatting">Link</a>) 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.</sub></p>