Wants to copy data if more than one table available on website

Ankur Teotia

New Member
Joined
Feb 16, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
HI Team - I am unable to copy second table on website as the below code only help to get first table of the website not getting second table of the website as well using the below code
Please help me here in completing the code


Sub getPPA()

Dim IE As New InternetExplorerMedium
IE.Visible = False
IE.Navigate ("Midway Authentication Portal")
Do While IE.Busy = True
DoEvents
Loop
Do While IE.ReadyState <> READYSTATE_COMPLETE
DoEvents
Loop
Do While IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0) Is Nothing
DoEvents
Loop
Dim rowCount As Integer
rowCount = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr").Length
With Sheets("dash")
For i = 0 To rowCount - 1
.Cells(i + 1, 1) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(0).innerText
.Cells(i + 1, 2) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(1).innerText
.Cells(i + 1, 3) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(2).innerText
.Cells(i + 1, 4) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(3).innerText
.Cells(i + 1, 5) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(4).innerText
.Cells(i + 1, 6) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(5).innerText
.Cells(i + 1, 7) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(6).innerText
.Cells(i + 1, 8) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(7).innerText
.Cells(i + 1, 9) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(8).innerText
.Cells(i + 1, 10) = IE.document.getElementById("secondaryProductivityList").getElementsByTagName("tbody")(0).getElementsByTagName("tr")(i).getElementsByTagName("td")(9).innerText

Next i
End With
End Sub
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Hi Ankur,

Unable to check site as it's asking for credentials.

meanwhile you can use Power Query to scrape the data from any table.
  1. Goto Data tab and under Get & Transform group, click on arrow next to Get Data.
  2. Click on From Other Sources and select From web option.
  3. In From Web window, enter the URL in URL field and click Ok button.
  4. Select the complete URL and press Connect button. (if window opens)
  5. Once it will connect, it will open Navigator window.
  6. In Navigator window, It will show different tables available in the page.
  7. Select the table one by one and check, in which table required data is available.
  8. Select the corresponding table and press Load or LoadTo button as required.
  9. The required data will be import in excel.


Regards,
Saurabh
 
Upvote 0
Aplogies...Site having privacy

I had already tried by using power query in which we are unable to reach on table

Anyhow we have to create vba

If Possible then help me in fetching second table whereas all elements are same as we had used for first table

If poosible kindly share your watsapp number if have any i would be more clear there
 
Upvote 0

Forum statistics

Threads
1,214,535
Messages
6,120,090
Members
448,944
Latest member
sharmarick

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