excel - Morningstar expected return -
i have code have tweaked below. use scrape other morningstar data, can't seem make work "expected return" etfs(exchange traded funds). on code right set data need having problem getting on excel spreadsheet. when msgbox tbltr under code:
set tbltr = doc.getelementsbyclassname("pr_text3")(4).innertext
i expected value on message box.
however, when take msgbox code out, value doesn't appear in excel spreadsheet. have been trying work out hours , need help!
below entire code. under tab "tickers2" have tickers pull data. examples jke, jkf, jkd...which have 1000. under tab "expectedreturn" want data displayed. think has me pulling elementsbyclassname versus when used pull elementsbytagname. there wasn't in tagnames in information needed switched class name. below entire code.
i mention have signed in morningstar.com in order actual data, assuming forum can point me in right direction without needing signed in.
the website www.morningstar.com
sub expectedreturn() 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 last_row = sheets("tickers2").range("a1").end(xldown).row ini_row_dest = 1 sheets("expectedreturn").select sheets("expectedreturn").range("a1:h10000").clearcontents application.screenupdating = true = 1 lastrow application.statusbar = "updating updown" & & "/" & last_row row_dest = ini_row_dest + (i - 1) strcode = "tickers2" ' range("a" & i).value list_symbol = sheets("tickers2").range("a" & i) ie.navigate "http://etfs.morningstar.com/quote?t=" & list_symbol while ie.readystate <> 4: doevents: loop set doc = createobject("htmlfile") set doc = ie.document tryagain: set tbltr = doc.getelementsbyclassname("pr_text3")(4).innertext msgbox tbltr if tbltr nothing goto tryagain on error resume next 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 sheets("expectedreturn").range("a" & row_dest).value = list_symbol next range("a3").select application.statusbar = false application.calculation = xlautomatic end sub
thank in advance.
-eddie
by setting
set tbltr = doc.getelementsbyclassname("pr_text3")(4).innertext
the variable tbltr string. want dom element, remove .innertext
only can loop on td-children further down.
Comments
Post a Comment