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
 

Some videos you may like

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple

Saurabhj

Active Member
Joined
Jun 6, 2020
Messages
413
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

Ankur Teotia

New Member
Joined
Feb 16, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
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
 

Watch MrExcel Video

Forum statistics

Threads
1,127,313
Messages
5,623,929
Members
416,000
Latest member
teabag

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
Top