Guides / Google Sheets

How to Get Latitude and Longitude from an Address in Google Sheets

November 8, 2026 · 4 min read

You have a list of addresses in Google Sheets and you need their latitude and longitude. You might be putting pins on a map, measuring distances, or importing into another tool. Google Sheets has no built-in function for this, but there are two free ways to do it.

For a few addresses: copy from Google Maps

  1. Open Google Maps and search for the address.
  2. Right-click the red pin (on a phone, press and hold it).
  3. The coordinates appear at the top of the menu, like 35.4676, -97.5164. Click them to copy.
  4. Paste into your sheet. The first number is the latitude and the second is the longitude.

To split a pasted pair into two columns, select the cells and use Data → Split text to columns, with a comma as the separator.

For many addresses: a GEOCODE formula

Google Sheets can run small scripts called Apps Script, and Apps Script can use Google's own geocoder. With about 20 lines of code you get a =GEOCODE() formula that works like any other.

1. Add the script

In your spreadsheet, click Extensions → Apps Script. Delete anything in the editor, paste this, and click Save (the disk icon):

/**
 * Latitude and longitude for an address. Fills two cells: latitude, then longitude.
 * @param {string} address The address to look up.
 * @return Latitude and longitude.
 * @customfunction
 */
function GEOCODE(address) {
  address = String(address || "").trim();
  if (!address) return [["", ""]];
  var cache = CacheService.getDocumentCache();
  var saved = cache.get(address);
  if (saved) return JSON.parse(saved);
  var res = Maps.newGeocoder().geocode(address);
  if (res.status !== "OK") return [[res.status === "ZERO_RESULTS" ? "Not found" : "Try again later", ""]];
  var loc = res.results[0].geometry.location;
  var out = [[loc.lat, loc.lng]];
  cache.put(address, JSON.stringify(out), 21600);
  return out;
}

Close the Apps Script tab and go back to your sheet.

2. Use the formula

Leave two empty columns for the results. In the first one, type =GEOCODE( followed by the cell with the address:

=GEOCODE(A2)

If the address is split across columns (street, city, state, ZIP), join them with &:

=GEOCODE(B2&", "&C2&", "&D2&" "&E2)

The formula fills two cells: latitude in the cell you typed it in, and longitude in the cell to its right. Keep that second cell empty, or you'll see a #REF! error.

The first time, Google asks you to authorize the script. Click Review permissions, choose your account, and allow it. A warning that Google hasn't verified the app is normal for a script you wrote yourself: click Advanced, then Go to (your project).

3. Copy it down

Drag the fill handle (the small square at the bottom right of the cell) down your list. Each row looks up its own address.

Freeze the results when you're done

Custom formulas recalculate now and then, and each lookup counts toward Google's daily limit for your account. Once your list is final, turn the formulas into plain numbers:

  1. Select the latitude and longitude columns.
  2. Copy them (Ctrl+C, or ⌘+C on a Mac).
  3. Click Edit → Paste special → Values only.

New rows can still use the formula. Freeze them after they fill in.

Common problems

"Not found." The geocoder couldn't match the address. Add the city and state or ZIP, fix typos, or drop suite numbers and building names.

"Try again later," or a "Service invoked too many times" error. You've hit the daily lookup limit for your Google account. Google doesn't publish an exact figure, and it varies by account type, but it's plenty for hundreds of addresses a day. Wait until tomorrow, or work in batches and freeze each batch.

**#REF! "Array result was not expanded."** The cell to the right isn't empty. Clear it so the longitude has somewhere to go.

**#NAME? "Unknown function."** The script isn't saved in this spreadsheet. Each spreadsheet needs its own copy: repeat step 1.

The coordinates are in the wrong place. Check the address is specific. "Springfield" alone could be one of dozens of towns. Including the state and ZIP fixes most of these.

What to do with them

With latitude and longitude in your sheet you can:

  • Import into Google My Maps to put every location on one shareable map (our store locator guide walks through it)
  • Measure the distance between two points, using the haversine formula
  • Show the locations on your website in a searchable list with a map

For that last one, the Location Finder reads your sheet and shows a list beside a map. It adds Near me sorting, a distance filter, and call and directions links. The finished version of this GEOCODE formula is included (it also handles whole ranges at once). It works on Squarespace (every plan), WordPress or any website, for $29 once.