jamescooper
Well-known Member
- Joined
- Sep 8, 2014
- Messages
- 840
Hello trying to get this to loop:
Any ideas please?
Code:
Sub WebData_2()
Dim lastRow As Long
Dim x As Long
Dim urls As Variant
Dim Prices As Variant
'Create sheet
lastRow = Sheets("7th Aug 2019").Range("H" & Rows.Count).End(xlUp).Row
urls = Sheets("7th Aug 2019").Range("H11:H" & lastRow).Value
For x = LBound(urls) To UBound(urls)
Prices = getprices(urls(x, 1))
Sheets("7th Aug 2019").Cells(Sheets("7th Aug 2019").Rows.Count, 1).End(xlUp).Offset(1).Resize(UBound(Prices), 17).Value2 = Prices
Next x
End Sub
Private Function getprices(ByVal URL As String) As Variant
Dim source As Object
Dim http As New XMLHTTP60, html As New HTMLDocument
With http
.Open "GET", URL, False
.send
html.body.innerHTML = .responseText
End With
Sheets("7th Aug 2019").Range("F5").Value2 = html.querySelector(".price-details--wrapper .value").innerText
Sheets("7th Aug 2019").Range("G5").Value2 = html.querySelector(".price-per-quantity-weight .value").innerText
End Function
Any ideas please?