Public Sub getdirections()
Dim xmlhttp As New MSXML2.XMLHTTP60, myurl As String, c As Range, rng As Range, xmlresponse As New DOMDocument60
Dim myarray() As Variant, x As Long, d As Range, lastrow As Integer, rng2 As Range
'take cells and make it read like it's supposed to for the api stuff
Worksheets("Sheet1").Columns("F").Replace _
What:=" ", Replacement:="+", _
SearchOrder:=xlByColumns, MatchCase:=True
'finds the last row and assigns integer value
lastrow = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
'setting range length dynamically
rngstr = "f1:f" & lastrow
Set rng = Range(rngstr)
'this is for the array call later
rngstr2 = "g1:g" & lastrow
Set rng2 = Range(rngstr2)
'single substitution to get one location will work on looping in a bit
For Each c In rng
myurl = "http://www.mapquestapi.com/directions/v2/route?key=key" & c & "&outFormat=xml&ambiguities=ignore&routeType=shortest"
'Debug.Print myurl
'sending the request
xmlhttp.Open "GET", myurl, False
xmlhttp.Send
xmlresponse.LoadXML (xmlhttp.ResponseText)
'once I got XML returns instead of JSON returns all started to work properly
Set stats = xmlresponse.SelectNodes("//response/route/distance")
'Sheets(1).Range("e2").Value = stats(0).Text
ReDim Preserve myarray(x)
myarray(x) = stats(0).Text
x = x + 1
'Range("d2 & rng").Value = stats(0).Text
Next
For x = LBound(myarray) To UBound(myarray)
Debug.Print myarray(x)
Next x
Private Sub CommandButton1_Click()
Application.Run "'C:\Users\location\Documents\CODE\Logisticare disputable trips by address22.xlsx '!getdirections"
End Sub