This code might work for you.
Change the references in the red lines to fit your case.
Sub GetDistances()
Dim IE As Object
Dim wsSource As Worksheet, rngSource As Range, c As Range
Dim fldFrom As Object, fldTo As Object, fldDist As Object, fldCost As Object, Cost As String, arrDist
Set wsSource = ThisWorkbook.Worksheets("Sheet1")
Set rngSource = wsSource.Range("A1:A15")
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
IE.Navigate "https://www.theaa.com/driving/mileage-calculator.jsp"
While (IE.Busy) Or (IE.ReadyState <> 4)
DoEvents 'pass control to other applications
Wend
For Each c In rngSource
Set fldFrom = IE.Document.all.Item("routeFrom")
fldFrom.Value = c.Value
While (IE.Busy) Or (IE.ReadyState <> 4)
DoEvents 'pass control to other applications
Wend
Set fldTo = IE.Document.all.Item("routeTo")
fldTo.Value = c.Offset(, 1).Value
While (IE.Busy) Or (IE.ReadyState <> 4)
DoEvents 'pass control to other applications
Wend
Call IE.Document.parentWindow.execScript("aaMC.fn.onGetRouteClicked()", "JavaScript")
Set fldDist = Nothing
While fldDist Is Nothing
Set fldDist = IE.Document.all.Item("routeDistanceTotal")
Wend
arrDist = Split(fldDist.innertext, vbCrLf)
c.Offset(, 2) = arrDist(0)
c.Offset(, 3) = arrDist(1)
Set fldCost = IE.Document.all.Item("routeExpenseTotalRow")
Cost = fldCost.innertext
Cost = Trim(Mid(Cost, 14))
Cost = Replace(Cost, vbCrLf, "")
Cost = Replace(Cost, vbCr, "")
c.Offset(, 4) = Cost
IE.Document.all.Item("mcDeleteRoutesLink").Click
While (IE.Busy) Or (IE.ReadyState <> 4)
DoEvents 'pass control to other applications
Wend
Application.Wait (Now + 1 / 24 / 60 / 60)
Next
IE.Quit
End Sub