excel - Append data from multiple xls files into one using VBA -


i trying achieve following using vba macro:

  • i have multiple .xls files, of have 1 sheet
  • in macro, want append data other files 1 sheet, appending them @ bottom of document behind each other. have figured out iterating through files, copying , appending data bugging me.

the code have until follows (missing parts described within comments)

sub iterate_files()  dim fso object, objfolder object, objsubfolder object dim frompath string dim fileinfolder object  frompath = activeworkbook.path set fso = createobject("scripting.filesystemobject") set objfolder = fso.getfolder(frompath)  each objsubfolder in objfolder.subfolders     each fileinfolder in objsubfolder.files     'copy data sheet 1 of fileinfolder     'to end of sheet in file :/     next fileinfolder next objsubfolder  end sub 

the following code appears have solved problem:

sub iterate_files()  dim fso object, objfolder object, objsubfolder object dim frompath string dim fileinfolder object  frompath = activeworkbook.path set fso = createobject("scripting.filesystemobject") set objfolder = fso.getfolder(frompath) set targetwb = activeworkbook  r = 0 each objsubfolder in objfolder.subfolders     each fileinfolder in objsubfolder.files         set wbsource = workbooks.open(fileinfolder)         wbsource.worksheets(1).usedrange.copy destination:=targetwb.worksheets(2).cells(r + 1, 1)         r = r + 15         wbsource.close savechanges:=false     next fileinfolder next objsubfolder  end sub  private sub rokaj_click()     iterate_files end sub 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -