javascript - Pulling Upside/downside Capture Ratio from morningstar.com -
first time long time.
new vba thing, catching on.
i'm interested in pulling upside/downside capture ratio lot of mutual funds , want automate process. table taking info not typical table; guess it's "dynamic object" on morningstar's website here website.
http://performance.morningstar.com/fund/ratings-risk.action?t=fdsax®ion=usa&culture=en-us
this specically sunamerica's focus dividend fund; want many funds here have code right now; got msgbox, don't know how loop , information on excel.
private sub worksheet_change(byval target range) if target.column=range("updown").row , _ target.column= range("updown").column dim ie new internetexplorer ie.visible=false ie.navigate "http://performance.morningstar.com/fund/ratings-risk.action?t=" _ & range("updown").value doevents loop until ie.readystate = readystate_complete dim doc htmldocument set doc = ie.document dim str string 'got "tr" google chrome inspect element str = trim(doc.getelementsbytagname("tr")(45).innertext) this stuck. know need used 'split' in order line item each of data need. example 1year upside 1 year downside 3 year upside 3 year downside.
so once on excel, need have excel run through of tickers...about 1500 pull data since updates once per month.
thank in advance...you'll life-saver...literally might shoot myself if don't figure out :)
try below code.
sub test() dim ie object, doc object, lastrow long, tbltr object, tbltd object, strcode string lastrow = range("a65000").end(xlup).row set ie = createobject("internetexplorer.application") ie.visible = true = 1 lastrow strcode = "fdsax" ' range("a" & i).value ' kindly change per requirement. hardcoded ie.navigate "http://performance.morningstar.com/fund/ratings-risk.action?t=" & "fdsax" 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 nothing goto tryagain j = 2 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
Comments
Post a Comment