I have the below code that will pull through data from a table on the first page of a website (Price, name, currency, change etc)
Public Sub GetTeamData()
Dim strWebAddress As String
Dim strH2AnchorContent As String
Dim IEDocument As MSHTML.HTMLDocument
Dim objH2 As MSHTML.HTMLHeaderElement
Dim obTable As MSHTML.HTMLTable
Dim objRow As MSHTML.HTMLTableRow
Dim objCell As MSHTML.HTMLTableCell
Dim lngRow As Long
Dim lngColumn As Long
' initialize some variables that should probably better be passed as paramaters or defined as constants
strWebAddress = "https://toolkit.financialexpress.net/santanderam"
dateNow = Now
bExitLoop = False
lngTimeoutInSeconds = 5
Do While Not bExitLoop
If Now > DateAdd("s", lngTimeoutInSeconds, dateNow) Then Exit Do
Loop
' open page
Set IEDocument = GetIEDocument(strWebAddress)
If IEDocument Is Nothing Then
MsgBox "Timeout reached opening this address:" & vbNewLine & strWebAddress, vbCritical
Exit Sub
End If
Dim ButtonData As Variant
Set ButtonData = IEDocument.getElementsByClassName("paginator fe-paging-navContainer")
Dim button As MSHTML.HTMLLinkElement
For Each button In ButtonData
Debug.Print button.nodeName
button.Click
' retrieve anchor element
Set oTable = IEDocument.getElementById("Price_1_1")
Debug.Print oTable.innerText
' iterate over the table and output its contents
lngRow = 1
For Each objRow In oTable.Rows
lngColumn = 1
For Each objCell In objRow.Cells
Cells(lngRow, lngColumn) = objCell.innerText
lngColumn = lngColumn + 1
Next objCell
lngRow = lngRow + 1
Next
Next button
End Sub
My problem is that I cannot get the data to pull through from the next pages (1..7).
Can anyone please help with why the above wont pull data through from the next pages? Thank you!
After the bit of code that opens the page, replace the rest of the code with the below code. You might have to tweak it a bit but it should go through all available pages: