There has been a lot of interest in using the Google API in Excel VBA for geocoding.
This article demonstrated a method of returning latitude and longitude coordinates from an address
and this article showed how to return an elevation from latitude and longitude coordinates.
So, I decided to combine the techniques from both articles to create an UDF that would use an address to give the elevation of that location. The first line of code illustrates the function arguments.
Function ElevationFromAddress(address As String, Optional ToFeet As Boolean) As Double
An address string is the 1st argument and there is an optional 2nd boolean argument for coverting meters to feet. Please feel free to download the example file containing the complete code for the UDF
The Google API algorithm can recognize locations with limited or detailed address information. The first two records in the table are for locations at a considerable altitude. The next record is for a Baptist seminary in Fort Worth, Tx. The last records are both for The White House in Washington, D.C. Note that the values are different – the first record must be for the front gate while the generic address refers to the actual building. As shown in the figure, the formulas in column B use the 2nd optional argument to return the elevation in feet.
This function procedure requires a reference to Microsoft XML, v6.0, selected in the VBE under Tools, References, as shown here.
The file can be downloaded here.