Hello all,
I was wondering if someone could help with the last piece of the puzzle. With numerous guides and code snippets I've managed to get the below partially working, however, what I would like is for the resulting data to be pulled in to Excel. I know it is possible, but cannot figure out how to do it.
The code below does everything the way I want, however I cannot pull the resulting data back in to Excel after "get element by ID convert" has run.
For info, column A (any column really, doesn't matter) contains a list of UK postal codes (example data below):
Can anyone help? Where it pastes the data to is irrelevant at the moment. Any help greatly appreciated.
Code
Sub PasteScrapeVERYWIP()
'This is working ok, but CANNOT workout how to extract data back to Excel...............
Dim IE As InternetExplorer
Dim htmlDoc As HTMLDocument
Dim el As HTMLFormElement
Dim pasteValues As String
Dim Vals As Range
Dim R As Long
Dim C As Long
'Dim clipboard As Object
'## Store the values
Set Vals = Range("A1:A50")
For R = 1 To Vals.Rows.Count
For C = 1 To Vals.Columns.Count
If Not C = 1 Then
pasteValues = pasteValues & vbTab & Vals(R, C)
Else:
pasteValues = pasteValues & vbNewLine & Vals(R, C)
End If
Next
Next
'## Open IE
Set IE = New InternetExplorer
IE.Visible = True
IE.navigate "https://gridreferencefinder.com/postcodeBatchConverter/"
Do Until IE.readyState = 4
DoEvents
Loop
Set htmlDoc = IE.document
Set el = htmlDoc.getElementById("inputData")
el.innerText = pasteValues
'## convert and select data
htmlDoc.getElementById("convert").Click
'htmlDoc.getElementById("outputData").Copy
'htmlDoc.getElementById("outputData").Select
Set IE = Nothing
End Sub
Display More