Hi! I want to grab all the search results from this page: Motorcycles | eBay I have a macro that grabs the first 200, how can I change it to grab all of them instead? Thanks!
Code:
Sub ListURLs()
Dim Anchors As Object
Dim HTMLdoc As Object
Dim Rng As Range
Dim row As Long
Dim URL As Variant
Dim Wks As Worksheet
URL = "http://www.ebay.com/sch/Motorcycles-/6024/i.html?_nkw=&_dcat=6024&rt=nc"
Set Wks = Worksheets("Sheet1")
Set Rng = Wks.Range("A2")
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", URL, False
On Error Resume Next
.Send
On Error GoTo 0
If .Status <> 200 Then
MsgBox "Server Error: " & .Status & " - " & .StatusText
Exit Sub
End If
Set HTMLdoc = CreateObject("htmlfile")
HTMLdoc.Write .responseText
HTMLdoc.Close
Set Anchors = HTMLdoc.getElementsByTagName("A")
For Each URL In Anchors
If URL.className = "vip" Then
Rng.Offset(row, 0).Value = URL.href
row = row + 1
End If
Next URL
End With
Set HTMLdoc = Nothing
End Sub