# Latitude and Longitude in Excel: Calculate Distance, Convert Degrees, and Geocode Addresses

If you have a long list of geographic coordinates to work with, a Microsoft Excel spreadsheet is sure to be useful. There are three basic Excel tools that can work for you, no matter how you want to manipulate your geographic coordinates. You’ll need to know how to calculate the distance between two latitude and longitude points, how to convert latitude and longitude data to decimal degrees, and finally, how to geocode latitudes and longitudes.

## How to Calculate the Distance Between Two Coordinates in Excel

In an example of how to calculate the distance between two coordinates in Excel, we’ll seek to measure the great circle distance. We’ll note that latitude and longitude are denoted in degrees, minutes and seconds.

## Convert Latitude and Longitude to Decimal Degrees in Excel

Everything, including something as complicated as degrees, minutes, and seconds, can be converted into decimals. The degrees part remains the same, but minutes and seconds need to be converted into their percentage of a degree and combined. There are 60 minutes in a degree and 60 seconds in a minute (which means 3,600 seconds in a degree). Therefore, divide minutes by 60 and seconds by 3,600.

The overall formula:

**Total Degrees (in the decimal form) = Deg + [Mins / 60] + [Seconds / 3600]**

### …So About That Distance

Now that you have the latitude and longitude values in decimals, you just face the equation for the nautical miles between Timbuktu and Casablanca, noted underneath.

**Nautical Miles**= ACOS [(sin(Lat_place_1*PI()/180)*sin(Lat_place_2*PI()/180)+

cos(Lat_place_1*PI()/180)*cos(Lat_place_2*PI()/180)*

cos(Lon_place_2*PI()/180-Lon_place_1*PI()/180)) ] *3443.8985

That three thousand number, in the end, is the radius of Earth, in, Nautical Miles. Even if you were to substitute it with the radius of a sphere, assuming the Earth is spherical, at 3437.7468 NM, you will not be near the real, accurate distance.

## Geocode Latitude and Longitude in Excel

Geocoding is the conversion of street addresses to latitude and longitude data that can be mapped. Now, there are two ways to geocode latitude and longitude from an Excel spreadsheet: the hard way and the easy way.

We’ll cover the hard way first, which is what you’ll need if you require the coordinates to live in your Excel document. You’ll need to write the Visual Basic (VBA) script to make a call to an external geocoder, or find the code elsewhere, such as this GitHub repo. There are a number of geocoder APIs and some geocoders are faster than others.

The Google Maps Geocoding API is a common choice and this is the API we’ll call in the easy option. However, it also can work directly within Excel. Armed with the code you’ve written or discovered, here are the steps to deploy geocoding within Excel.

**Step 1:** Find the Developer tab in your version of Excel.

**Step 2:** Look for the “Visual Basic” tab. This opens the development window.

**Step 3:** Insert —> Module. The new module will hold your function.

**Step 4:** **Here is where you copy and paste your code**.

**Step 5:** We need to add references now. So, Tools —> References. Make sure to check the Microsoft XML v6.0. CLICK OK.

**Step 6:** Press CTRL / CMD + S. Save as type —> Excel Add-In. Now you get to name your function. The extension has to be .xlam. Time to close all Excel files.

**Step 7:** Open a new file. File —> Options —> Add-Inns. In the Manage box, choose Excel-Add Ins.

**Step 8:** Press Go. Choose your function in the window that appears by ticking in the box. Press OK.

**Step 9:** VOILA. Now you could just use the new function you created, like any other function.

After you are done retrieving the values, copy and paste them elsewhere, off of the sheet with the calculations. Then delete the function calls because otherwise when you reopen this file, the Google API will start to be pinged again. That will eat up several minutes before the file is open. To optimize Google resource usage, take a 10-second break between addresses.

That’s a lot of steps, and assumes you’ve found some code to try out. Next, we’ll see the easier way to geocode your Excel data. It’s fast and reliable, but it won’t import the coordinates into your Excel file. On the other hand, the excel geocoding tool is copy-paste simple and gets you an interactive map.

## Create a Map with Excel

There are a number of ways to create maps with Excel data. Perhaps the easiest is to just copy and paste your spreadsheet data into our map-making tool. Doing so turns your Excel document into a beautiful, interactive map like the one below.

View Example Latitude/Longitude Map in a full screen map

To make your own map based on latitude and longitude coordinates, separate the coordinates into their own columns within your spreadsheet.

Then, select and copy the rows and columns of your spreadsheet (Ctrl+C command or Cmd+C on Mac) and navigate to batchgeo.com. Paste (Ctrl+V or Cmd+V on Mac) in your data, and you’re done!

Whether you want to make a latitude and longitude map or create your own virtual wedding guide for your guests, BatchGeo provides a free and easy way to make beautiful web maps that are ready to be saved and shared.