mrmmickle1
Well-known Member
- Joined
- May 11, 2012
- Messages
- 2,461
I have been using some code I found originally posted by Norie to pull down web tables off of a page:
However this only pulls down only first 50 rows of the table....or what is visible on the web page.
Is there a way to pull down the entire table?
The table ID is "playerrater_0"
When I navigate to the next 50 results the url changes to:
Player Rater - Free Fantasy Basketball - ESPN
The problem is there are 905 rows in the table
Any help would be appreciated.
Rich (BB code):
Option Explicit
Sub TableExample()
Dim IE As Object
Dim doc As Object
Dim strURL As String
strURL = "Player Rater - Free Fantasy Basketball - ESPN?" ' replace with URL of your choice
Set IE = CreateObject("InternetExplorer.Application")
With IE
'.Visible = True
.Navigate strURL
Do Until .ReadyState = 4: DoEvents: Loop
Do While .Busy: DoEvents: Loop
Set doc = IE.Document
GetAllTables doc
.Quit
End With
End Sub
Sub GetAllTables(doc As Object)
' get all the tables from a webpage document, doc, and put them in a new worksheet
Dim ws As Worksheet
Dim rng As Range
Dim tbl As Object
Dim rw As Object
Dim cl As Object
Dim tabno As Long
Dim nextrow As Long
Dim I As Long
Set ws = Worksheets.Add
For Each tbl In doc.getElementsByTagName("TABLE")
tabno = tabno + 1
nextrow = nextrow + 1
Set rng = ws.Range("B" & nextrow)
rng.Offset(, -1) = "Table " & tabno
For Each rw In tbl.Rows
For Each cl In rw.Cells
rng.Value = cl.outerText
Set rng = rng.Offset(, 1)
I = I + 1
Next cl
nextrow = nextrow + 1
Set rng = rng.Offset(1, -I)
I = 0
Next rw
Next tbl
ws.Cells.ClearFormats
End Sub
However this only pulls down only first 50 rows of the table....or what is visible on the web page.
Is there a way to pull down the entire table?
The table ID is "playerrater_0"
When I navigate to the next 50 results the url changes to:
Player Rater - Free Fantasy Basketball - ESPN
The problem is there are 905 rows in the table
Any help would be appreciated.