VBA table code

Hi All, 

I am learninig VBA. The below code is to extract table data for 1 web page. 

I need to extract the data from a list of web urls. How can i do this?

Can anyone help me on this?

Sub Test()

Dim html As Object

Dim tbl As Object

Dim tRow As Object

Dim tCel As Object

Dim X As Long

Dim y As Long

With CreateObject(“MSxml2.XMLHTTP”)

.Open “GET”, “https://www.cesco.com/Eaton-Cooper-Lighting-SHK-Cooper-Lighting-SHK-Fixture-Hook-With-2-1-2-Inch-Safety-Screw-Die-Cast-Aluminum/p2085509”, False


Set html = CreateObject(“htmlfile”)

html.body.innerHTML = .responseText

End With

For Each tbl In html.getElementsByTagName(“table”)

For Each tRow In tbl.getElementsByTagName(“tr”)

For Each tCel In tRow.getElementsByTagName(“td”)

y = y + 1

If y = 2 Or y = 4 Then

Cells(X + 1, IIf(y = 2, 1, 2)) = tCel.innerText

End If

Next tCel

y = 0

X = X + 1

Next tRow

Next tbl

End Sub

Hi @pradeepvvce,

This post was moved to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our Community organized so users can more easily find information.

As you’ll notice, your Topic is now in the Project Development Help and Advice board. No action is needed on your part; you can continue the conversation as normal here.

Let me know if you have any other questions or if I can help with anything else.