BlogHow-To

Calculate Distance Between Two Addresses in Google Sheets

5 July 2026·8 min read

To calculate the distance between two addresses in Google Sheets, install the free InstaMaps add-on and use the formula =DISTANCE(A2, B2). It calculates the straight-line distance in miles or kilometres based on the exact coordinates of the locations provided in the specified cells.

This process is designed for sales managers defining service territories, real estate analysts comparing property values, and operations teams scheduling field visits. By the end of this guide, you will have a functional spreadsheet that accurately measures spatial gaps, identifies the nearest locations automatically, and maps your addresses without leaving your standard workspace.

TL;DR
  • Install the free InstaMaps add-on to access spatial formulas in Google Sheets.
  • Use =DISTANCE(A2, B2) to calculate the straight-line gap between two addresses.
  • The formula measures 'as the crow flies' rather than driving distance along roads.
  • Apply =SORT_BY_DISTANCE() to automatically order a list of candidates by proximity.
  • Use =CLOSEST_TO() to instantly identify the nearest location to a target address.
  • Map your entire dataset using =INSTAMAP() to generate a live, hosted shareable URL.

What you need to calculate distance

To begin measuring spatial relationships in Google Sheets, you need a standard Google account and the InstaMaps add-on. Google Sheets does not include native formulas for geographic distance calculations, so a third-party tool is required to bridge that gap.

Open your browser, navigate to the Google Workspace Marketplace, and install InstaMaps. Once authorised, launch the tool from your sheet by clicking Extensions > InstaMaps > Formulas. This opens a sidebar menu that inserts spatial formulas automatically, meaning you do not need to memorise the exact syntax to build your distance calculator.

InstaMaps operates on a freemium model that is entirely free for standard users. The base tier provides 100 lookups per day. If your project requires a higher volume, you can unlock 1,000 lookups per day at no cost simply by registering an email address. You will need your addresses structured in standard columns before applying the formulas.

Step 1: Calculate straight-line distance using =DISTANCE()

The core function for measuring spatial gaps is =DISTANCE(). This function evaluates two points-either written addresses or geographic coordinates-and outputs the mathematical measurement between them.

In a typical setup, column A contains your origin addresses and column B contains your destinations. To measure the gap for the first row, input the following formula into cell C2: =DISTANCE(A2, B2).

If cell A2 contains 'Tower Bridge, London' and cell B2 contains 'Wembley Stadium, London', the formula fetches the latitude and longitude of both locations and returns the physical distance (roughly 10.5 miles or 16.9 kilometres). You can specify the output unit by adding a third parameter, such as =DISTANCE(A2, B2, "mi") or =DISTANCE(A2, B2, "km"). It is vital to note that this calculates the straight-line distance 'as the crow flies', not the driving distance along road networks.

  1. Formula: =DISTANCE(A2, B2, "mi")

  2. Cell A2: 1600 Amphitheatre Pkwy, Mountain View, CA

  3. Cell B2: 1 Infinite Loop, Cupertino, CA

  4. Result: 8.7

Step 2: Identify the closest location using =CLOSEST_TO()

When managing a list of potential destinations, you often need to know which single location is nearest to a specific origin point. The =CLOSEST_TO() function evaluates a single target against an array of candidates and returns the best match.

Assume cell A2 contains your client's address, and cells B2 through B50 contain a list of your company's regional service centres. To find the nearest centre automatically, use the formula: =CLOSEST_TO(A2, B2:B50).

The cell will display the exact address of the nearest centre from your list. This eliminates the need to manually calculate the distance for every single location and sort the numbers yourself, saving hours of administrative labour when assigning regional accounts or dispatching field technicians to maintenance jobs.

Step 3: Sort a list by proximity using =SORT_BY_DISTANCE()

If you need to organise a complete dataset by proximity rather than finding just one match, use =SORT_BY_DISTANCE(). This function takes a target address and a larger range of data, then reorders the output based on what is closest to the origin.

Using the previous scenario, if you want to see all your service centres ranked from nearest to furthest for the client in cell A2, input: =SORT_BY_DISTANCE(A2, B2:B50).

The formula will output a sorted, vertically expanding array of addresses. This is particularly useful when the closest location is fully booked or unavailable, as the next closest options are already listed directly beneath it. You can pair this with the =INSTAMAP() formula to generate a live, hosted shareable map URL that visually represents this sorted list and automatically updates whenever you alter the underlying addresses.

Worked example: Routing a 47-stop delivery route

Consider an independent agricultural supplier managing deliveries for a local farming community. The dispatcher has a list of 47 distinct farm addresses that need feed deliveries on a specific Tuesday. The depot is located in cell A2, and the 47 destination addresses are listed in cells B2 down to B48.

First, the dispatcher uses =CLOSEST_TO(A2, B2:B48) to determine the logical first stop for the lead driver. Next, they apply =SORT_BY_DISTANCE(A2, B2:B48) to create an ordered manifest, allowing the 5 separate delivery crews to divide the 47 stops into efficient geographic zones rather than driving back and forth across the county.

Once the manifest is finalised, the dispatcher uses =ROUTE_LINK(A2:B48) to generate a clickable hyperlink. This formula uses Google Maps' official URL scheme to push the stops directly into turn-by-turn navigation. Note that the route link is limited to a maximum of 11 stops per link, so the dispatcher groups the 47 stops into separate daily route links for each crew.

Limits and honest alternatives

InstaMaps is highly effective for address validation, proximity sorting, and spatial mathematics, but it has specific limitations based on your operational scale and routing complexity.

The daily lookup cap of 1,000 free calculations (with email verification) covers most small-to-medium business needs. If you have a database of 50,000 historical contacts to clean, you will exceed this limit quickly and may need to spread the work across several days. Furthermore, the =DISTANCE() formula calculates straight-line geometry, not dynamic road conditions.

If your business requires live traffic avoidance, toll cost calculation, or strict route sequencing for a massive fleet of vehicles, InstaMaps is not a replacement for enterprise logistics software. Paid Transport Management Systems (TMS) pull live road data and optimise for current traffic patterns. InstaMaps bridges the gap for teams that need quick, accessible spatial awareness directly within their spreadsheets without purchasing complex software licenses.

Try it free

Map your Salesforce accounts in under 5 minutes — no admin setup.

Install Free →

Common Questions

Can Google Sheets calculate distance between two addresses?

No, Google Sheets cannot calculate distance natively. You must install a third-party add-on like InstaMaps from the Google Workspace Marketplace to access custom formulas such as =DISTANCE() that perform these mathematical calculations.

How do I measure distance in Google Sheets?

Once the InstaMaps add-on is installed, input =DISTANCE(A2, B2) into a cell, replacing A2 and B2 with the cells containing your addresses. The add-on will output the measurement in your specified unit of measurement.

Does the distance formula measure road miles?

No, the =DISTANCE() formula calculates the straight-line distance between two latitude and longitude points. It does not account for roads, traffic conditions, or physical driving routes. It measures the direct geographic gap.

How do I sort addresses by distance in Google Sheets?

You can use the InstaMaps add-on and input the =SORT_BY_DISTANCE(target, range) formula. This automatically reorders a list of addresses based on which location is physically closest to your specified target address.

Start calculating distances in your spreadsheets

Install InstaMaps for free to measure spatial gaps, find your closest locations, and map your spreadsheet data without leaving Google Sheets.

Install InstaMaps free