Get tabledata from webpage into Excel using macro -
i use excel sheet calculation, assessment of incometax returns. need pull data website excel sheet. did using vba step step
- create internet explorer application in vba
- navigate website url , login
- fill form automatically unique id in excel sheet
- now submit form , result page has data in table form
- now using
getelementsbyid("tableid")
copied , pasted data in excel sheet.
my question
- all tables don't have id or name
- there lot of tables
now want pull data table without id third table top. how this? tried hard. don't want tables because rows in these tables changed when copy tables data.
start macro recording, go data -> web, open required web page in import dialog, select required table, set import options needed, , import data. stop recording.
you boiler plate auto generated macro code, trivial fine turn needs.
i did many times , easy haven't stored snipped share right now.
update: how import question page
sub macro1() ' ' macro1 macro ' ' activesheet.querytables.add(connection:= _ "url;http://stackoverflow.com/questions/18158928/get-tabledata-from-webpage-into-excel-using-macro/18160278#18160278" _ , destination:=range("$a$1")) .name = "18160278#18160278" .fieldnames = true .rownumbers = false .filladjacentformulas = false .preserveformatting = true .refreshonfileopen = false .backgroundquery = true .refreshstyle = xloverwritecells ' adjust setting needs .savepassword = false .savedata = true .adjustcolumnwidth = true .refreshperiod = 0 .webselectiontype = xlspecifiedtables .webformatting = xlwebformattingnone .webtables = "1" ' number of required table on page .webpreformattedtexttocolumns = true .webconsecutivedelimitersasone = true .websingleblocktextimport = false .webdisabledaterecognition = true .webdisableredirections = false .refresh backgroundquery:=false end end sub
Comments
Post a Comment