Calculate Distance or Duration Between Two Locations Using Google Sheets OS_DIRECTION

Introduction

If you're seeking a convenient method to determine the distance or travel duration between two locations using Google Sheets, look no further. OneScript's custom function, OS_DIRECTION, offers a seamless solution for this task. By leveraging the Google Directions API, this function streamlines the process of obtaining this data for any two locations.

Installation

Install from Google Workspace Marketplace

YouTube

If you're more of a visual learner, watch this video for step-by-step instructions. While you're there, consider subscribing to my channel for future updates and content.



Demo Use Case

In this demonstration, we are calculating the distance from “Times Square, New York, NY” to “Central Park, New York, NY” by driving.

Example

OS_DIRECTION("Times Square, New York, NY", "Central Park, New York, NY", 1, 1)

About

Calculate distance or duration between two locations. Powered by Google Maps API.


origin

The start address.

destination

The end address.

mode

1 - Driving, 2 - Transit, 3 - Walking, 4 - Cycling (Default to 1).

metric

1 - Distance, 2 - Duration, 3 - Both (Default to 1).

* The unit of distance value is meter and the unit of duration value is second.

OneScript Custom Functions (Follow for More Updates)

Links

Hire Me on Upwork Donate YouTube Github Twitter / X Instagram Upwork Projects

Comments