How To Parse an Address in Excel by Macro/VBA

2.5 min read|Last Updated: February 10th, 2024|Categories: excel|
table of content

Do you have an address and are looking for extracting the address line, city, state (province), country and zip code (postal code)? In this blog, we will explain how to make an Excel file to parse an address. If you’re interested in a custom solution for your Excel file, please contact our Excel expert consultant team for a free quote.

Google API Key

We used Google Geocoding API to extract the information from an address. To use Google API, you’re required to have a Google API key.

Demo

Feel free to download a demo of the Excel XLSM file.

 

How the Excel file works?

  1. In range C1, type the address that you want to parse, for example “1455 Crown St Ste A, North Vancouver, BC”.
  2. In range C2, enter your Google API key.
  3. Click “Parse Address” button. In the yellow area marked by “Google Map Address Structure”, the processed address by Google will be displayed.

Development

If you are familiar with VBA Editor and creating buttons, you can copy/paste the following VBA code into your VBA editor. And create a button to execute this function.

Then, install Json Converter developed by https://github.com/VBA-tools/VBA-JSON. i.e. create a module called “JsonConverter” and copy/paste the code written in the Github link in the module.

Once you copy/paste the code and created a button, type an address in range C1, and your Google API key in range C2. Then click the butt