|
楼主 |
发表于 2011-8-25 17:57
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub combo()
Dim Wk As Workbook, Sht As Worksheet, n As Integer, MyPath, MyName
Application.ScreenUpdating = False
Application.EnableEvents = False
n = 1
MyPath = ThisWorkbook.Path & "\" '指定路径
MyName = Dir(MyPath & "\" & "*.xls") '寻找第一项
Do While MyName <> "" '开始循环
If MyName <> ThisWorkbook.Name Then
Set Wk = Workbooks.Open(MyPath & "\" & MyName)
Wk.Sheets(1).Copy after:=ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count) '此处只插个第一个sheet
ThisWorkbook.Sheets(ThisWorkbook.Sheets.Count).Name = Mid(MyName, 1, Len(MyName) - 4) '重新命名sheet
'For Each Sht In Wk.Sheets '多个sheet
'Sht.Name = Format(n, "000″)
'n = n + 1
'Next
Wk.Close False
End If
MyName = Dir '查找下一个
Loop
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
上述是合并各工作簿第一张表的代码,不知道哪位高手可以将其修改成我需要的复制指定工作表的代码? |
|