J
Joel
This request disappeared from the postings. do'nt know why. Here is the
solution
Sub Private Commandbutton1_Click()
Postcode = InputBox("Enter PostCode: ")
Postcode2 = InputBox("Enter 2nd PostCode: ")
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = _
"http://www.postcode.org.uk/country/uk/_postcode-distance-calculator.asp"
IE.Navigate2 URL
Do While IE.readyState <> 4 Or IE.busy = True
DoEvents
Loop
Set MyForm = IE.document.getElementsByTagname("Form")
Set inputform = MyForm.Item(0)
Set Postcodebox = inputform.Item(0)
Postcodebox.Value = Postcode
Set Postcodebox2 = inputform.Item(1)
Postcodebox2.Value = Postcode2
Set POSTCODEbutton = inputform.Item(2)
POSTCODEbutton.Click
Do While IE.readyState <> 4 Or IE.busy = True
DoEvents
Loop
Set Table = IE.document.getElementsByTagname("Table")
Set DistanceTable = Table.Item(3)
Set DistanceRow = DistanceTable.Rows(2)
distance = Val(Trim(DistanceRow.Cells(2).innertext))
With Worksheets("sheet1")
.Range("A1").Value = distance
End With
IE.Quit
End Sub
solution
Sub Private Commandbutton1_Click()
Postcode = InputBox("Enter PostCode: ")
Postcode2 = InputBox("Enter 2nd PostCode: ")
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
URL = _
"http://www.postcode.org.uk/country/uk/_postcode-distance-calculator.asp"
IE.Navigate2 URL
Do While IE.readyState <> 4 Or IE.busy = True
DoEvents
Loop
Set MyForm = IE.document.getElementsByTagname("Form")
Set inputform = MyForm.Item(0)
Set Postcodebox = inputform.Item(0)
Postcodebox.Value = Postcode
Set Postcodebox2 = inputform.Item(1)
Postcodebox2.Value = Postcode2
Set POSTCODEbutton = inputform.Item(2)
POSTCODEbutton.Click
Do While IE.readyState <> 4 Or IE.busy = True
DoEvents
Loop
Set Table = IE.document.getElementsByTagname("Table")
Set DistanceTable = Table.Item(3)
Set DistanceRow = DistanceTable.Rows(2)
distance = Val(Trim(DistanceRow.Cells(2).innertext))
With Worksheets("sheet1")
.Range("A1").Value = distance
End With
IE.Quit
End Sub