Hi, I am getting the following error message when I run the code below. The code works perfectly well when I used it on different websites.
Run-time error '91':
Object variable or With block variable not set
I am not sure if its the code or the website that's causing the error?
Sub Sample()
Dim IE As New InternetExplorer
Dim sht As Worksheet
Dim rRng As Range
Dim ele As Object
Dim lRow As Range
Dim LastRow As Long
Dim name As String
Set sht = ThisWorkbook.Worksheets("Sample")
sht.Range("D3:M1000").Select
Selection.ClearContents
IE.navigate "website address"
Do While IE.Busy = True Or IE.readyState <> 4: DoEvents: Loop
Set Doc = IE.document
LastRow = sht.Cells(sht.Rows.Count, "D").End(xlUp).Row
y = 3
For Each ele In Doc.getElementsByClassName("c-table-container").getElementsByTagName("Table")(0).getEelementsByTagName("tbody")(0).getElementsByTagName("tr")
name = Trim(ele.getElementsByTagName("td")(2).innerText)
sht.Range("D" & y).Value = name
y = y + 1
Next
IE.Quit
Set IE = Nothing
'ActiveWorkbook.Save
End Sub
Any suggestions? Thank you.
Bookmarks