In this article:

Calculate Distance Between Two Addresses in Google Sheets [2024 Update]

December 5, 2024

How to Calculate the Distance Between Two Addresses in Google Sheets

We have the following sheet with two addresses:

can google sheets calculate distance between two addresses‍

Let us find the distance between them, specifically the driving distance between them using a custom script. Here are the steps:

1. Click Extensions then Select Apps Script

In Google Sheets, click Extensions then select Apps Script.

Click extensions select apps script‍

A new tab will load for Google Apps Script, showing the code area.

Empty apps script code area

2. Copy the Script and Paste it to Apps Script

We will copy the script for calculating distances between two addresses to the Apps Script. Click the link below first, then copy the script in it:

Google Sheets Distance Between Two Addresses Custom Functions Script

Script to calculate distance between two addresses in google sheets‍

You can click this icon to copy the entire code:

Copy script for calculating distance

Once done, go back to the Apps Script tab. Clear the code area then paste the code to it.

Pasting distance between two distances‍

Click Save project.

Save script in google apps script‍

3. Use =DRIVEDIST(origin,destination,unit) Function

The DRIVEDIST function finds the distance you need to drive from one location to another. The syntax is

=DRIVEDIST(origin, destination, unit)

Where

Origin and Destination are the addresses where you start and end your travel; and

Unit is the unit of distance you want to use. 

The units you can use are the following:

  • km for kilometers
  • mi for miles
  • nm for nautical miles
  • m for meters
  • ft for feet

Enclose them in double quotes.

For example, we want to find the distance between the two addresses, where the origin is in cell C1 and the destination is in cell C2. We want to find the distance in kilometers. The formula becomes:

=DRIVEDIST(C1, C2, “km”)

Calculate driving distance between two addresses 

4. Press Enter

Press Enter to run the formula. The result is automatically calculated!

Google sheets calculate distance between two addresses‍

Just take note of the unit used in calculating the driving distance between the two addresses.

How to Calculate the Geographical Distance Between Two Addresses in Google Sheets

Sometimes we want to find the distance between two points separated by bodies of water:

Google sheets function to calculate two distances between two addresses‍

The DRIVEDIST function will not work because there is no continuous road connecting these two places. In fact, there is an ocean separating them! But how can we find the distance between them? Don’t worry, that’s what GEODIST is for! Here are the steps in using the GEODIST function. If you already followed the steps above, you can skip Steps 1 and 2 and go straight to Step 3. 

1. Click Extensions then Select Apps Script

In Google Sheets, click Extensions then select Apps Script.

Click extensions select apps script to calculate distance between two addresses‍

A new tab will load for Google Apps Script, showing the code area.

Empty google apps script code area

2. Copy the Script and Paste it to Apps Script

We will copy the script for calculating distances between two addresses to the Apps Script. Click the link below first, then copy the script in it:

Google Sheets Distance Between Two Addresses Custom Functions Script

Script to calculate distance between two addresses in google sheets

You can click this icon to copy the entire code:

Copy script for calculating distance

Once done, go back to the Apps Script tab. Clear the code area then paste the code to it.

Pasting distance between two distances

Click Save project.

Save script in google apps script

3. Use =GEODIST(origin,destination,unit) Function

The DRIVEDIST function finds the geographical distance between two addresses. The syntax is

=GEODIST(origin, destination, unit)

Where

Origin and Destination are the addresses where you start and end your travel; and

Unit is the unit of distance you want to use. 

The units you can use are the following:

  • km for kilometers
  • mi for miles
  • nm for nautical miles
  • m for meters
  • ft for feet

Enclose them in double quotes.

For example, we want to find the distance between the two addresses, where the origin is in cell C1 and the destination is in cell C2. We want to find the distance in kilometers. The formula becomes:

=GEODIST(C1, C2, “km”)

Calculate geographical distance between two addresses ‍

4. Press Enter

Press Enter to run the formula. The result is automatically calculated!

Google sheets Calculate geographical distance between two addresses ‍

Just take note of the unit used in calculating the geographical distance between the two addresses.

Get Google Sheets productivity and automation tips delivered straight to your inbox
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
We'll email you 1-3 times a week — and never share your information.

Work less, automate more!

Use Lido to connect your spreadsheets to email, Slack, calendars, and more to automate data transfers and eliminate manual copying and pasting. View all use cases ->