excel - User Open CSV Into Tab Using VBA -
i trying button when pressed prompts user open csv file , bunch of other things automatically performed on csv file. here code working with:
sub mainmacro() dim fnameandpath variant fnameandpath = application.getopenfilename(filefilter:="excel files (*.csv), *.csv", title:="select file opened") if fnameandpath = false exit sub workbooks.open filename:=fnameandpath 'sheets.add after:=sheets(sheets.count) 'activesheet.name = fnameandpath call macro1 call macro2 call macro3 call macro4 end sub
put opens csv file , want open in tab , marco1 marco2...
can perform respective tasks. button perform of mainmacro() on newly active sheet user loaded in.
this code open csv , copy worksheet original workbook will. on copying sheet destination workbook, copied sheet activate.
sub mainmacro() dim csvwb workbook dim fnameandpath variant fnameandpath = application.getopenfilename(filefilter:="excel files (*.csv), *.csv", title:="select file opened") if fnameandpath = false exit sub set csvwb = workbooks.open(filename:=fnameandpath) csvwb.worksheets(1).copy before:=thisworkbook.worksheets(1) csvwb.close call macro1 call macro2 call macro3 call macro4 end sub
of course, depending on macro1-4 do, may easier open in different workbook , perform macros against that?
Comments
Post a Comment