VBA to scrape Web scroll-table into excel

bezuchoff

New Member
Joined
May 31, 2018
Messages
3
Hello,

I have been trying putting together a code to get scroll table data from web to excel from an internal url which does not open in IE. The code I have, however, only takes table (column) headings, not the values from table itself. The table on web updates every once a while on would be great get it into excel. I have table ID, table data (cells) contain links as well as dynamic values.

Any help would be highly appreciated. Thanks a lot.


Sub ScpareWebTable()

Dim xml As Object
Dim html As MSHTML.IHTMLDocument
Dim objTable As Object
Dim result As String
Dim trow As Object
Dim tcel As Object


Set xml = CreateObject("MSXML2.XMLHTTP.6.0")
With xml
.Open "GET", "https://company_xx.internal.co.uk/station/linehaul", False
.send
End With


result = xml.responseText
Set html = CreateObject("htmlfile")


html.body.innerHTML = result


Set objTable = html.getElementsByTagName("table")


Set trow = html.getElementsByTagName("tr")
Set tcel = html.getElementsByTagName("td")

For Each tcel In trow
Debug.Print tcel.innerText
Next tcel

End Sub
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
One important comment - when I call the table by its ID Set objTable = html.getElementsById("linehaulDataTable") I am getting Run-time error 438 (Object doesn't support this property or method).
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,730
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top