Fetch data from website table using vba -


i need update excel file information, obtained following link (warning, ukrainian language): link ministry of finance web-site of ukraine

useful data wrapped html tags <tbody></tbody>.

i need similar code retrieves information table

set htm = createobject("htmlfile")' #it doesn't work on mac os machine, performs on windows     createobject("msxml2.xmlhttp")         .open "get", <site_url_goes_here>, false         .send         htm.body.innerhtml = .responsetext     end      htm.getelementbyid("item")' <<<<<---what should write here in order parse data web-site table?         sheet2.cells(row, 4).value = p         x = 1 .rows.length - 1             y = 0 .rows(x).cells.length - 1                 sheet2.cells(row, y + 1).value = .rows(x).cells(y).innertext             next y             row = row + 1         next x     end with` 

below code updated data http://www.minfin.gov.ua in every 60 seconds.

sub getdata()      application.ontime + timeserial(0, 0, 60), "finance_data"  end sub  private sub finance_data()     dim url string, lastrow long     dim xmlhttp object, html object     dim tbl object, obj_tbl object     dim tr object, td object     dim row long, col long      lastrow = range("a" & rows.count).end(xlup).row      url = "http://www.minfin.gov.ua/control/uk/publish/article?art_id=384069&cat_id=234036" & "&r=" & worksheetfunction.randbetween(1, 10000)      set xmlhttp = createobject("msxml2.xmlhttp")     xmlhttp.open "get", url, false     xmlhttp.setrequestheader "content-type", "text/xml"     xmlhttp.send      set html = createobject("htmlfile")     html.body.innerhtml = xmlhttp.responsetext     set obj_tbl = html.getelementsbytagname("table")      row = 1     col = 1      each tbl in obj_tbl         if tbl.classname = "msonormaltable"             set tr = tbl.getelementsbytagname("tr")              each obj_row in tr                 each td in obj_row.getelementsbytagname("td")                     cells(row, col) = td.innertext                     col = col + 1                 next                 col = 1    ' reseting value                 row = row + 1             next         end if     next      getdata end sub 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -