iFocus.Life News News - Breaking News & Top Stories - Latest World, US & Local News,Get the latest news, exclusives, sport, celebrities, showbiz, politics, business and lifestyle from The iFocus.Life,

How to Calculate Distances Between Zip Codes in VBA

104 20
    • 1). Declare variables for the zip codes you want to find the distance between by typing the following code into the top of your VBA program:

      Set zip1 = "12345"

      Set zip2 = "54321"

    • 2). Type the following code under your zip code values declaration:

      Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")

      URL = "http://maps.google.com/maps/nav?output=js&oe=utf8&q=from:" & zip1 & "+to:" & zip2

      objHTTP.Open "GET", URL, False

      objHTTP.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"

      objHTTP.send ("")

    • 3). Press F5 to run your macro and return the distance between the two zip codes.

Subscribe to our newsletter
Sign up here to get the latest news, updates and special offers delivered directly to your inbox.
You can unsubscribe at any time
You might also like on "Society & Culture & Entertainment"

Leave A Reply

Your email address will not be published.