Calculate the Center/Average of Multiple Coordinate Points with Excel VBA
I wanted to calculate a good center/average point for a cluster of geographic coordinates in Excel VBA and came across a JavaScript solution here . All I had to do was rewrite all the logic in VBA. The only real challenge was realizing that Excel's Atan2 function takes (x, y) while JavaScript's atan2 function takes (y, x). Here is my solution: Function AverageGeolocation ( ByRef aCoords ) As Coord '''Calculate the center/average of multiple Geolocation coordinates '''Expects array of objects named Coord with .latitude and .longitude properties Dim cOut As New Coord Dim x As Double Dim y As Double Dim z As Double Dim latitude As Double Dim longitude As Double Dim i As Long Dim Math As Object Dim total As Double Dim centralLongitude As Double Dim centralSquareRoot As Double...