Web scraped data not being sent to Excel

Viewed 34

I would be very grateful if someone could please help me. I'm a novice at VBA so please have sympathy on me as I have spent ages trying to get the results into the Excel sheet.

The code below runs and populates the immediate table with the results when the debug statement isn't commented out.

The code below completes without any errors, but Sheet2 does not contain any results.

I've searched the internet and youtube videos, but cannot find anything that works.

If someone could please tell what the code should be to populate Sheet2 with the results, Id be extremely grateful. Thank you.

Option Explicit
Dim driver As New selenium.ChromeDriver

Sub Scrape()
Set driver = CreateObject("Selenium.ChromeDriver")

Dim tdHeaders As selenium.WebElements
Dim tdHeader As selenium.WebElement
Dim WSc As Integer
Dim WSr As Integer
WSc = 1
WSr = 2

driver.Get ("webaddress")


Set tdHeaders = driver.FindElementsByTag("td")
For Each tdHeader In tdHeaders

   Sheet2.Cells(WSr, WSc).Value = tdHeader.Text
'  Debug.Print tdHeader.Text

    WSc = WSc + 1
Next tdHeader


End Sub
0 Answers
Related