I would like to get the top Gainer of the S&P500 (The Company that registered the highest stock surge in percentage) and put it on an excel cell.
I use the data from this website :
http://www.quotenet.com/index/market-movers/S&P_500
Unfortunately when I analyse the source code with my Browser the first entry of the table does not have an id so I don't know how to recognize it in my code.
Here is what I have written so far :
Dim ie As InternetExplorer, doc As HTMLDocument,, topmover As String
Set ie = CreateObject("InternetExplorer.Application")
ie.navigate "http://www.quotenet.com/index/market-movers/S&P_500"
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set doc = ie.document
'topmover= doc.getElementBy???
edit :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ie As InternetExplorer, doc As HTMLDocument, rng As Range, ticker As String, topmover As String
Dim TopMoverTable As Object
Set rng = Sheets("Sheet1").Range("A1")
ticker = rng.Value
Set ie = CreateObject("InternetExplorer.Application")
If Target.Row = rng.Row And Target.Column = rng.Column Then
ie.navigate "http://www.quotenet.com/index/market-movers/S&P_500"
Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE
Set doc = ie.document
Set TopMoverTable = doc.getElementsByTagName("TABLE")(2)
Cells(1, 2) = Split(TopMoverTable.getElementsByTagName("TD")(0).innerText, vbCrLf)(0)
Cells(1, 3) = Split(TopMoverTable.getElementsByTagName("TD")(4).innerText, vbCrLf)(1)
Cells(2, 2) = Split(TopMoverTable.getElementsByTagName("TD")(1).innerText, vbCrLf)(0)
Cells(2, 3) = Split(TopMoverTable.getElementsByTagName("TD")(4).innerText, vbCrLf)(1)
End If
ie.Application.Quit
End Sub
Do you Know can I get the first entry of the first Table ? Thank you