永发信息网

如何将一个文件夹中的多个excel文件中相同名称sheet中的固定行的数据按照顺序汇总到一个新的excel表中?

答案:2  悬赏:80  手机版
解决时间 2021-02-27 23:52
  • 提问者网友:趣果有间
  • 2021-02-27 09:34
文件夹下含多个excel文件,每个excel文件有1-12月的12个sheet,要求在此文件夹中构建一个新的excel表,能够将所有excel文件中指定月份sheet中的第66-76行中的所有数据汇总到新的excel表中!求大神帮助!!!!!!!!!!!!
最佳答案
  • 五星知识达人网友:蓝房子
  • 2021-02-27 10:56
写个程序一键处理
全部回答
  • 1楼网友:酒者煙囻
  • 2021-02-27 12:34
sub 多文件汇总()     dim wb as workbook, sh as worksheet, ash as worksheet     application.screenupdating = false     pth = thisworkbook.path & "\"     fn = dir(pth & "*.*")     do while fn <> ""       if instr(fn, ".xls") > 0 then         set wb = workbooks.open(pth & fn)         if wb.name <> thisworkbook.name then             for each sh in wb.sheets                 set ash = thisworkbook.sheets(sh.name)                 if ash is nothing then                      set ash = thisworkbook.sheets.add(after:=thisworkbook.sheets(thisworkbook.sheets.count))                      ash.name = sh.name                 end if                 sh.usedrange .copy                 ash.cells(rows.count, 1).end(3).offset(1).paste                 set ash = nothing             next         wb.close         doevents       end if       fn = dir     loop     application.screenupdating = true end sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯