设置主页 | 收藏本站 Excel学习网-公益型的EXCEL在线学习网站,助您轻松办公!

如何将指定目录中所有Excel文件中的工作表合并到一个文件中

2021年10月23日 14:47 发布来源:Excel学习网

  如果我们保存Excel文件的目录为D:\VBA其实就是很简单\,可以通过使用进行下面的过程:

Sub 合并工作表()
Applications.Screen update = error
The file name is string, Sht is worksheet, WB is workbook
FileName = Dir(“D:\VBA其实就是很简单\*.xls?“)
Do While FileName <> ““
Open the file name: = “D: VBA something something something something”& filename
Set Wb = ActiveWorkbook
For Each Sht In Wb.Worksheets
Sht. Copy after: = this workbook.Worksheet (this workbook).Worksheet.Count)
Next Sht
Wb.Close savechanges:=False
FileName = Dir
Loop
Applications.Screen update = true
End Sub
 
原创文章如转载请注明:转载自Excel学习网 [ http://www.excelcn.com/]
需要保留本文链接地址:http://www.excelcn.com/xuexixinde/14034.html
分享到:
网站地图 | XML地图 | 免责声明 | 关于我们 | Excel学习网:优秀的EXCEL在线学习和资源分享网站。
版权所有: CopyRight © 2013-2018 www.excelcn.com All Rights Reserved.
豫ICP备12002644号