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.

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.


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


Data validation is used to create two drop down lists for city names, and an INDEX formula in the adjacent cell returns the mileage between those cities. The MATCH function finds the row for the starting city, and the column for the destination city.

Here’s the formula that returns the mileage:



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, you can download the sample 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, please watch this short video.



You may also like...

2 Responses

  1. Alan Millar says:

    I like the formula but how can i generate the chart for a number of towns in UK

  2. Jennifer says:

    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 *