|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 批量复制工作表()
Dim MYSHT As Worksheet, WB As Workbook, FSO As Object, MYFD As Object, FS As Object, F
Set MYSHT = ThisWorkbook.Sheets(1) '把Sheets(1)中的1改成实际要复制的工作表,可用工作表名称(需加引号,"工作表名称")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set MYFD = FSO.GETFOLDER(ThisWorkbook.Path & "\文件夹1") '根据实际文件夹名修改
Set FS = MYFD.Files
Application.ScreenUpdating = False
Application.DisplayAlerts = False
For Each F In FS
Set WB = Workbooks.Open(F.Path)
MYSHT.Copy , WB.Sheets(WB.Sheets.Count)
WB.Close True
Next
Application.DisplayAlerts = True
Application.ScreenUpdating = True
Set MYSHT = Nothing
Set FSO = Nothing
Set MYFD = Nothing
Set FS = Nothing
Set WB = Nothing
End Sub |
|