title: In Excel - find the second (or nth) closest location from a list of coordinates
body: <p>For example, the below table shows origin coordinates in the blue highlighted cells and possible destinations in the green highlighted cells.</p>
  
  <p><a href="https://i.stack.imgur.com/RGCrq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RGCrq.png" alt="Coordinates table"></a>
  The 'ClosestSiteID' field identifies the SiteID of the destination coordinate set that is closest to the origin coordinate set.  </p>
  
  <p>For reference, the formula used in cell A2 is: </p>
  
  <p><code>=LOOKUP(1,1/FREQUENCY(0,SIN((RADIANS(G$2:G$11-$D2))/2)^2+SIN((RADIANS(H$2:H$11-$E2))/2)^2*COS(RADIANS(G$2:G$11))*COS(RADIANS($D2))),$F$2:$F$11)</code></p>
  
  <p>How do I modify this formula to select the second or nth closest destination for a given origin to populate column B?</p>