Excel 2010 VBA Copy Data from Multiple Excel Files -


i have search , searched , have come close not perfect. here goes...

what need code work through other excel work books in succession , copy data. files named 1,2,3,4 etc 60 max. have code open files works great. next need go of work books , copy set data , return main workbook have been able well. here problems...

  1. i know there must way write code 1 time , have work through remaining files. ie. if first file named 1.csv can code on 1.csv, on 1.csv + 1 meaning 2.csv , loop out? seems should able it. don't want have manually work way through writing same code copy 1.csv way 60.csv

  2. if there way loop how end end if part. ie 1 week there might 37 files , next 40 , on. want start @ file 1.csv , work until gets last active file either 37.csv or 60.csv , end if there no 38.csv file.

here basic recorded code have.

   public sub testr()   dim filenum integer   dim lastrow long    filenum = 1   on error goto my_handler        windows(filenum & ".csv").activate     range("a25").select     range(selection, activecell.specialcells(xllastcell)).select     selection.copy     windows("test.xlsm").activate     range("a1").select     lastrow = worksheets("data").cells(1, 1).end(xldown).row     activesheet.paste     filenum = filenum + 1   loop  my_handler:   msgbox "all done."   exit sub end sub 

any give me amazing! in advance~

okay, code have now, need @ least edit this:

public sub testr()   dim filenum integer   filenum = 1   on error goto my_handler        windows(filenum & ".csv").activate     range("a25").select     range(selection, activecell.specialcells(xllastcell)).select     selection.copy     windows("test.xlsm").activate     range("a1").select     activesheet.paste     range("a1").select     filenum = filenum + 1   loop  my_handler:   msgbox "all done."   exit sub end sub 

Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -