First Time Long Time.
New to this VBA thing, however catching on.
I\'m interested in pulling the upside/downside capture ratio for a lot of mutual funds and want
Try below code.
Sub Test()
Dim IE As Object, Doc As Object, lastRow As Long, tblTR As Object, tblTD As Object, strCode As String
lastRow = Range("A65000").End(xlUp).Row
Set IE = CreateObject("internetexplorer.application")
IE.Visible = True
For i = 1 To lastRow
strCode = "FDSAX" ' Range("A" & i).value ' kindly change it as per your requirement. Currently hardcoded
IE.navigate "http://performance.morningstar.com/fund/ratings-risk.action?t=" & "FDSAX"
Do While IE.readystate <> 4: DoEvents: Loop
Set Doc = CreateObject("htmlfile")
Set Doc = IE.document
tryAgain:
Set tblTR = Doc.getelementbyid("div_upDownsidecapture").getelementsbytagname("tr")(3)
If tblTR Is Nothing Then GoTo tryAgain
j = 2
For Each tblTD In tblTR.getelementsbytagname("td")
tdVal = Split(tblTD.innerText, vbCrLf)
Cells(i, j) = tdVal(0)
Cells(i, j + 1) = tdVal(1)
j = j + 2
Next
Next
End Sub