excel - Import Comma Delimited to Specific WorkSheet -


i trying import comma delimited text file specific sheet in workbook. code have imports it, cant figure out how tell go specific sheets thats created, right creates new sheet , dumps data in there.

the code have

'import report        dim vpath variant       dim wb excel.workbook       dim ws excel.worksheet        set wb = excel.activeworkbook       set ws = excel.sheets("data")       vpath = application.getopenfilename("csv (comma delimited) (*.csv),*.csv" _       , 1, "select file", , false)        ''//show file open dialog allow user select csv file        if vpath = false exit sub        ''//exit macro if no file selected        workbooks.opentext filename:=vpath, origin:=xlmsdos, startrow:=1 _       , datatype:=xldelimited, textqualifier:=xldoublequote, comma:=true _       , fieldinfo:=array(array(1, xltextformat), array(2, xltextformat), _       array(3, xltextformat))        ''//the fieldinfo array needs extended match number of columns        columns.entirecolumn.autofit        ''//resize columns        sheets(1).move before:=wb.sheets(1)        ''//move data workbook 

i think need add like;

destination:=range("sheet2!$a$1") 

somewhere, cant figure out where, everywhere ive tried has caused errors

here start:

sub csv_reader()       dim vpath variant       dim wb excel.workbook       dim ws excel.worksheet       dim rng range, textline string       dim rw long, col long       dim long, j long, ary() string, variant        set wb = excel.activeworkbook        vpath = application.getopenfilename("csv (comma delimited) (*.csv),*.csv" _          , 1, "select file", , false)       msgbox vpath       set rng = application.inputbox(prompt:="pick sheet , cell", type:=8)       rng.parent.parent.activate       rng.parent.activate       rw = rng(1).row       col = rng(1).column        close #1       = rw       open vpath input #1       while not eof(1)          line input #1, textline          ary = split(textline, ",")          j = col          each in ary             cells(i, j).value =             j = j + 1          next          = + 1       loop       close 1  end sub 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -