How to Perform Reverse Geocoding in Excel (with Easy Steps)

Get FREE Advanced Excel Exercises with Solutions!

Reverse geocoding means finding out the actual address or location from a given latitude and longitude. This task can be quite hectic if you want to perform it manually. But with the help of Excel, you can perform reverse geocoding easily. In this article, I will show you, how to perform reverse geocoding in Excel.

Reverse Geocoding in Excel: 5 Easy Steps

In this article, you will see five easy steps to perform reverse geocoding in Excel. To perform this task, I will need the help of VBA code to build a custom function for Excel. Then, by applying the custom function, I will find out the address from the latitude and longitude.

To illustrate my article further, I will use the following sample data set.

5 Easy Steps to Perform Reverse Geocoding in Excel

Step 1: Open Microsoft Visual Basic Application from Developer Tab

Firstly, to write a VBA code, you must open a module, as you cannot write it into a normal worksheet like other formulas. For that,

  • First of all, go to the Developer tab of the ribbon
  • Then from the Code group, select Visual Basic.

Opening Microsoft Visual Basic Application from Developer Tab as An Easy Step to Perform Reverse Geocoding in Excel

  • Secondly, you will see the Visual Basic window.
  • Afterward, from the Insert tab, choose Module.

  • Consequently, a module will look like the following image after opening where you will be able to write the code.

Read More: How to Convert Latitude and Longitude to Address in Excel

Step 2: Select Necessary Reference from Tool Option

In the second step, you will need to activate a particular reference so that the custom function can perform accurately. To do that,

  • Firstly, from the Tools tab of the VBA window, select References.

  • Secondly, you will see a list of available references in the References – VBAProject dialog box.
  • Then, from the list, select Microsoft XML, v3.0, and make sure the reference is marked.
  • Lastly, press OK.

Selecting Necessary Reference from Tool as An Easy Step to Perform Reverse Geocoding in Excel

Read More: How to Convert Address to Lat Long in Excel

Step 3: Use Code to Build Required Custom Function

Now for the third step, I will write the code that will create the custom function required for performing reverse geocoding. For that,

  • First of all, copy the following code and paste it into the module from the first step.
  • Here, I have named the custom functions as ReverseGecoder.
Option Explicit
Function ReverseGeocoder(lati As Double, longi As Double) As String
On Error GoTo 0
Dim xD As New MSXML2.DOMDocument
Dim URL As String, vbErr As String
xD.async = False
URL = "" + CStr(lati) + _
"&lon=" + CStr(longi)
xD.Load ("" + CStr(lati) + _
"&lon=" + CStr(longi))
If xD.parseError.ErrorCode <> 0 Then
Application.Caller.Font.ColorIndex = vbErr
ReverseGeocoder = xD.parseError.reason
xD.SetProperty "SelectionLanguage", "XPath"
Dim loca As MSXML2.IXMLDOMElement
Set loca = xD.SelectSingleNode(" / reversegeocode / result")
If loca Is Nothing Then
Application.Caller.Font.ColorIndex = vbErr
ReverseGeocoder = xD.XML
Application.Caller.Font.ColorIndex = vbOK
ReverseGeocoder = loca.Text
End If
End If
Exit Function
Debug.Print Err.Description
End Function

Writing Code to Build Required Custom Function as An Easy Step to Perform Reverse Geocoding in Excel

  • Secondly, after pasting the code save it, and go back to the worksheet with the coordinates.

Read More: Convert Latitude and Longitude to Decimal Degrees in Excel

Step 4: Implement Custom Function

In the fourth step, I will implement the custom function from the previous procedure and see if it really shows the address for a particular coordinate. To do that,

  • Firstly, into your Excel sheet, type =REV in cell D5 and you will see the auto-suggestion of the custom function from the previous step.
  • To select the function press Tab on the keyboard or double-click on the function using the mouse.

  • Secondly, to implement the function type the following formula in cell D5.

  • Finally, press Enter and see the desired location for the coordinates of cells B5 and C5.

Step 5: Show Final Result

This is the final step of this procedure. After completing all the previous steps, I will now show the final result or outcome. To do that,

  • First of all, you will find the AutoFill feature in the following image if you take your cursor at the lower right corner of cell D5.
  • After selecting it drag the feature to the lower to implement the formula in the lower cells as well.

  • Finally, you will be able to see all the locations by using the custom functions which work as a reverse geocoder.

Things to Remember

  • If you don’t activate the reference before implementing the custom function, it won’t show the desired result.
  • Your Excel file might act slower after implementing the function, so keep patience after using AutoFill.

Download Practice Workbook

You can download the free Excel workbook here and practice on your own.


That’s the end of this article. I hope you find this article helpful. After reading the above description, you will be able to perform reverse geocoding in Excel. Please share any further queries or recommendations with us in the comments section below.

We are always concerned about your preferences. Therefore, after commenting, please give us some moments to solve your issues, and we will reply to your queries with the best possible solutions.

Related Articles

What is ExcelDemy?

ExcelDemy Learn Excel & Excel Solutions Center provides free Excel tutorials, free support , online Excel training and Excel consultancy services for Excel professionals and businesses. Feel free to contact us with your Excel projects.
Md. Araf Bin Jayed
Md. Araf Bin Jayed

I am Araf. I have completed my B.Sc in Industrial and Production Engineering from Ahsanullah University of Science and Technology. Currently I am working as an Excel & VBA Content Developer in Softeko. With proper guideline and aid of Softeko I want to be a flexible data analyst. With my acquired knowledge and hard work, I want to contribute to the overall growth of this organization.

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF