Skip to content

Instantly share code, notes, and snippets.

@shobhit-ilfs
shobhit-ilfs / GetCoordinates.xml
Last active September 9, 2023 11:11
Excel add-in script for geocoding address to geographical coordinates in MS Excel
Option Explicit
Function GetCoordinates(Address As String) As String
'-----------------------------------------------------------------------------------------------------
'This function returns the latitude and longitude of a given address using the Google Geocoding API.
'The function uses the "simplest" form of Google Geocoding API (sending only the address parameter),
'so, optional parameters such as bounds, key, language, region and components are NOT used.
'In case of multiple results (for example two cities sharing the same name), the function
'returns the FIRST OCCURRENCE, so be careful in the input address (tip: use the city name and the