Hi Guys,
I have the below code which currently opens up a postcode website, searches an address ( made up from cells from row 2, column 4 + 5 ), then returns the search result into row 2 column 7... This works fine but doesn't seemt o loop properly, all the rows in the workbook get the same first post code pasted into every cell down column 7, anyone any idea? Thanks.
I have the below code which currently opens up a postcode website, searches an address ( made up from cells from row 2, column 4 + 5 ), then returns the search result into row 2 column 7... This works fine but doesn't seemt o loop properly, all the rows in the workbook get the same first post code pasted into every cell down column 7, anyone any idea? Thanks.
VBA Code:
Dim i As Long
i = 2
Do While Not IsEmpty(Cells(i, 4).Value)
IE.document.getElementsByName("val")(0).Value = Cells(i, 4) & " " & Cells(i, 5) & ", Edinburgh"
IE.document.forms(0).submit
Dim postcodeDiv As Object
Dim parts As Variant, Postcode As String
Do
Set postcodeDiv = IE.document.getElementsByClassName("postcode")(0)
DoEvents
Loop While postcodeDiv Is Nothing
parts = Split(postcodeDiv.innerText, "Postcode: ")
Postcode = Split(parts(1), vbCrLf)(0)
Cells(i, 7).Value = Postcode
i = i + 1
Loop