Hi,

I am new to this site and to Excel VBA.

I have a spreadsheet which contains two columns of UK postcodes(about 1,500).

The column A contains "from" and column B contains "To"
I want the vba to go to WWW.AA.com and insert the From/To postcodes into the route finder to obtain the Distance and Travel time.

I have managed to access the AA website using VBA and by hardcoding the From/To I have managed to get the route and time.

However, I would like to extract the Distance and Travel time I think the elements are called "routeDistanceValue" for Distance and Travel time "routeTimeDistance" from the website back into spreadsheet. I haven't been able to find out how to this action.

Following this action, I want the codes to go down a row and start the query again and put the next line's postcodes into the query.

Please can you help me with the code below




Macro 1 - simply checked that there are two postcodes, if there are two, it moves onto macro2

Sub macro1()
'test for previous postcode

If ActiveCell.Offset(0, -1) = "" Then ActiveCell.Offset(1, 0).Select Else Call macro2



End Sub


Sub macro2()
'This will call the the AA website and runs query


Dim ie As Object
Dim postcodefrom As String
Dim postcodeto As String


Let postcodefrom = ActiveCell.Offset(0, -1)
Let postcodeto = ActiveCell.Offset(0, -2)


Set ie = CreateObject("Internetexplorer.Application")
ie.Visible = True

ie.Navigate "http://www.theaa.com/route-planner/index.jsp?fromPlace=CV32 6RN&toPlace=WR12 7LJ"

the ie.Navigate requires changing to allow for the new postcodes. I have setup postcodefrom and postcodeto in preparation for this. But how do you adapt the code.

Any assistance will be very much appreciated.

Thanks in advance

Alan