|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 汇总工作簿中工作表()
Dim filePath, fileName, sht, wb As Workbook, Nam
filePath = ThisWorkbook.Path & "\"
Nam = ThisWorkbook.Name
fileName = Dir(filePath & "*.xls", vbDirectory)
Application.ScreenUpdating = False
Do While fileName <> ""
Set wb = GetObject(filePath & fileName)
For Each sht In wb.Worksheets
sht.copy after:=ThisWorkbook.Worksheets(ThisWorkbook.Worksheets.Count)
ActiveSheet.Name = sht.Name & "-" & Replace(wb.Name, ".xls", "")
' ActiveSheet.Name = sht.Name
Next
wb.Close
Set wb = Nothing
fileName = Dir()
Loop
Application.ScreenUpdating = True
End Sub
两个要汇总的表是xls,汇总的是xlsm,为什么导入时连汇总的xlsm中的的表也要导入,dir中指明了xls类型。Do While fileName <> nam,虽可解决问题,但指明文件类型为xls为什么会有问题?
|
|