title: Excel formula to calculate the distance between multiple points using lat/lon coordinates
body: <p>I'm currently drawing up a mock database schema with two tables: <code>Booking</code> and <code>Waypoint</code>.</p>
  
  <ul>
  <li>Booking stores the taxi booking information. </li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/iQUwz.png" alt="enter image description here"></p>
  
  <ul>
  <li>Waypoint stores the pickup and drop off points during the journey, along with the lat lon position. Each sequence is a stop in the journey.</li>
  </ul>
  
  <p><img src="https://i.stack.imgur.com/HbjM7.png" alt="enter image description here"></p>
  
  <p>How would I calculate the distance between the different stops in each journey (using the lat/lon data) in Excel? </p>
  
  <p>Is there a way to programmatically define this in Excel, i.e. so that a formula can be placed into the <code>mileage</code> column (<code>Booking</code> table), lookup the matching sequence (via <code>bookingId</code>) for that journey in the <code>Waypoint</code> table and return a result?</p>
  
  <p><strong>Example 1:</strong></p>
  
  <p>A journey with 2 stops:</p>
  
  <pre><code>1   1   1   MK4 4FL, 2, Levens Hall Drive, Westcroft, Milton Keynes 52.002529   -0.797623
  2   1   2   MK2 2RD, 55, Westfield Road, Bletchley, Milton Keynes   51.992571   -0.72753
  </code></pre>
  
  <p>4.1 miles according to Google, entry made in <code>mileage</code> column in <code>Booking</code> table where <code>id = 1</code></p>
  
  <p><strong>Example 2:</strong></p>
  
  <p>A journey with 3 stops:</p>
  
  <pre><code>6   3   1   MK7 7DT, 2, Spearmint Close, Walnut Tree, Milton Keynes 52.017486   -0.690113
  7   3   2   MK18 1JL, H S B C, Market Hill, Buckingham              52.000674   -0.987062
  8   3   1   MK17 0FE, 1, Maids Close, Mursley, Milton Keynes        52.040622   -0.759417
  </code></pre>
  
  <p>27.7 miles according to Google, entry made in <code>mileage</code> column in <code>Booking</code> table where <code>id = 3</code></p>