Get Mileage from Excel Lookup Table

Get Mileage from Excel Lookup Table

There is a new sample file on my website, in response to a lookup question that someone asked on my Contextures Facebook page. The sample file shows how to get mileage from Excel lookup table, when you pick two cities.

Here is the question from the Facebook page:

I'm staring at a huge spreadsheet showing the distances in miles between a few hundred job sites…Our data is accurate, but the users often enter the wrong mileage data because it's easy to make a mistake when scrolling…

How can I automate this process so that I can just enter the departure site and the arrival site and retrieve the distance between the two?

The Mileage Table

To find data in a lookup table, based on the row and column headings, you can use the INDEX and MATCH functions. Here’s the mileage lookup table in my sample file, with cities in Florida.


NOTE: The numbers above, and to the left of the table aren’t used – they’re just there for visual verification of the formulas.


In the sample file, data validation is used to create two drop down lists for city names, in columns A and B. In column C, an INDEX formula returns the mileage between the two selected cities.

The MATCH function is used twice in the formula, to find:

  • the row for the starting city,
  • the column for the destination city.

Here’s the formula that returns the mileage:

=INDEX(G3:P12, MATCH(A3,F3:F12,0), MATCH(B3,G2:P2,0))


Highlight the Mileage for Selected Cities

As an extra way to verify the results, I’ve added conditional formatting in the lookup table, to highlight the cell with the mileage for the selected cities.


Here is the conditional formatting formula:


Download the Sample File

To see the formulas and the conditional formatting, download the Get Mileage from Excel Lookup Table file from my website. On the Sample Files page, look for FN0026 – Get Travel Distance from Mileage Chart

The file is zipped, and in xlsx format. There are no macros in the file.

Watch the Video

To see the steps for creating the lookup formula, watch this short video - Get Mileage from Excel Lookup Table.


0 thoughts on “Get Mileage from Excel Lookup Table”

  1. Do you have an easy way to generate the mileage chart? Where I work, we create a mileage chart by manually looking up the driving distance and time between clients. It would be nice to be able to enter an address and have the chart update automatically.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.