excel - QueryTables Method - irregular table size -
i handed vba macro written else no longer works company , asked add additional functions. macro uses querytables method, unfamiliar with, import data fixed-width text file excel. file has basic information in first row (date , time, recording number, etc.) , actual data begins in second row. text file has 4 columns , uses quotes indicate data 1 sensor ends , begins within column. example:
20140529 15:11:42 rec# 0001 'sensor1 ''sensor2 ''sensor3 ''sensor4 ' 0.00000 1500.00 1.05400e-01 0.123799e-02 0.100000 1510.00 -7.68900e-01 0.404716e-02 'sensor5 ''sensor6 ''sensor7 ''sensor8 ' 0.710000e-01 0.250000e-01 2.12500 1.87100 0.450000e-01 0.290000e-01 2.36200 2.19200
originally, macro start importing @ row 2, skipping on title info , pasting each sensor in it's own column. here's original querytables code:
' input unigraph file filename = "text;h:\modeshapedata.input" activesheet.querytables.add(connection:=filename, _ destination:=sheets("data").range("$a$1")) .name = "modeshapedata.input" .fieldnames = true .rownumbers = false .filladjacentformulas = false .preserveformatting = true .refreshonfileopen = false .refreshstyle = xlinsertdeletecells .savepassword = false .savedata = true .adjustcolumnwidth = true .refreshperiod = 0 .textfilepromptonrefresh = false .textfileplatform = 437 .textfilestartrow = 2 .textfileparsetype = xlfixedwidth .textfiletextqualifier = xltextqualifierdoublequote .textfileconsecutivedelimiter = false .textfiletabdelimiter = true .textfilesemicolondelimiter = false .textfilecommadelimiter = false .textfilespacedelimiter = false .textfilecolumndatatypes = array(1, 1, 1, 1) .textfilefixedcolumnwidths = array(18, 18, 18) .textfiletrailingminusnumbers = true .refresh backgroundquery:=false end
i changed .textfilestartrow
value 1 title info data, caused data imported looks in text file rather putting each sensor own column.
i can assume there's simple way title info imported, either leaving code alone , importing first row seperately or changing in block more 4 columns back.
update
i have found work-around problem leaving original code , creating additional subroutine again new sheet starting ay row 1 instead of row 2, , pull info sheet instead of data sheet. i'll leave here in case comes cleaner solution.
Comments
Post a Comment