shahin
Active Member
Hi there! I tried a lot to parse a table from a webpage but inability seized me and finally I ended up with nothing. Hope there somebody helps me figure out what exactly I am missing in my code. Thanks. This is the site: "http://www.tenh.com/available-freight-national-flatbed-carrier/"
Code:
Sub TableData()
Dim htmlas As Object, tRow As Object, tCel As Object
x = 2
With CreateObject("MSXML2.serverXMLHTTP")
.Open "GET", "http://www.tenh.com/available-freight-national-flatbed-carrier/", False
.send
Set html = CreateObject("htmlfile")
html.body.innerHTML = .responseText
End With
Set htmlas = html.getElementsByTagName("table")(0)
For Each tRow In htmlas.Rows
For Each tCel In tRow.Cells
y = y + 1
Cells(x, y) = tCel.innerText
Next tCel
y = 0
x = x + 1
Next tRow
Set htmlas = Nothing
End Sub