|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本帖最后由 约定的童话 于 2019-7-29 10:23 编辑
Sub 汇总()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
[D2:EA53] = ""
Dim ar, cr, Str As String, FilePath As String, n As Long, sht As Worksheet
FilePath = ThisWorkbook.Path & "\" '获取当前工作簿路径
Str = Dir(FilePath & "*.xls", vbNormal) '把工作簿名赋值变量
m = 4
Do While Str <> "" '遍历当前工作簿所在的文件夹
If Not (Str = "合并.xls") Then '判断工作簿名是否是要求,不是就执行下面代码
Set wb = Workbooks.Open(FilePath & Str) '打开工作簿
For Each sht In Workbooks(2).Sheets
sht.[d2:h53].Copy Workbooks("合并.xls").Sheets("汇总").Cells(2, m)
m = m + 5
Next
wb.Close False
End If
Str = Dir
Loop
MsgBox "汇总完毕", , "报告"
End Sub
|
评分
-
1
查看全部评分
-
|