Excel VBA: get specific table data from html table -
i'm trying pull main data table website using innerhtml , looping through bunch of different table data , mess (tried webquerytable format isn't right me) http://lcvpd.lt/lt/aktualijos/statistika/uzbsands.php
is there way extract main data table?
sorry bad communication, new vba , don't know how correctly explain sitaution.
here's far:
sub html_table_to_excel() dim htm object dim tr object dim td object dim tab1 object 'replace url of webpage want download web_url = vba.trim(sheets(1).cells(1, 1)) 'create htmlfile object set html_content = createobject("htmlfile") 'get webpage content htmlfile object createobject("msxml2.xmlhttp") .open "get", web_url, false .send html_content.body.innerhtml = .responsetext end column_num_to_start = 1 irow = 2 icol = column_num_to_start itable = 10 'loop through each table , download excel in proper format each tab1 in html_content.getelementsbytagname("table") html_content.getelementsbytagname("table")(itable) each tr in .rows each td in tr.cells sheets(1).cells(irow, icol).select sheets(1).cells(irow, icol) = td.innertext icol = icol + 1 next td icol = column_num_to_start irow = irow + 1 next tr end itable = itable + 1 icol = column_num_to_start irow = irow + 1 next tab1 end sub
Comments
Post a Comment