Count No of Tables on a certain Webpage and Import Data from Specific Tables into Excel through VBA

Kartick0075

New Member
Joined
Jan 9, 2020
Messages
18
Office Version
  1. 2019
Platform
  1. Windows
Dear All Respected Sirs,
Can you please give a solution on how should I count the number of tables on a certain Webpage? For your information, I tried the below code. But, instead of giving me the count of Total no of Tables on that Webpage, it's giving the count of Total no of Rows of all Tables on that page. Please anyone help me.
I'm giving my code below...
------------
Sub Count_Tables_on_a_Webpage ()
Dim IE as SHDocVw.InternetExplorer
Set IE = New ShDocVw.InternerExplorer

IE.Visible = True
IE.Navigate "https://www.wsj.com/ _
market-data/quotes/AAPL/ _
financials/annual/balance-sheet"

Do While IE.ReadyState <> ReadyState_Complete

Dim Doc as MSHTML.HTMLDocument
Set Doc = IE.Document

Dim TBL as MSHTML.IHTMLElement
Dim TBLs as MSHTML.IHTMLElementCollection

Set TBLs = Doc.getElementsbyTagName("Table")
MsgBox TBLs.Length
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,214,830
Messages
6,121,835
Members
449,051
Latest member
excelquestion515

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