title: IF duplicate cell value found in column then return value
body: <p>I need to track a person in a data sheet to determine from which location to which location the person moved. </p>
  
  <p>If a person appears more then one time in Column J that means the person has changed the location and the location value is in Column L. For this I have the following code:</p>
  
  <pre><code>=IF(J18=J19;IF(COUNTIF(J:J;J18)&gt;1; "From "&amp;L18 &amp;" to "&amp; IF(J18=J19;L19;"");"");"")
  </code></pre>
  
  <p>The problem is if the person changes the location more than two times. In Column O to Column AA I have the months of the year which determines the location of the person.</p>
  
  <p>How can I modify this code to do the above:</p>
  
  <pre><code>=IF(J18=J19;IF(COUNTIF(J:J;J18)&gt;1; "From "&amp;L18 &amp;" to "&amp; IF(J18=J19;L19;"");"");"")
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/rO0Rb.png" alt="Example"></p>