如何汇总多个EXCEL文件
发布网友
发布时间:2022-05-26 12:19
我来回答
共3个回答
热心网友
时间:2023-10-16 16:49
这是多文件合并
Sub 合并工作簿()
Dim FilesToOpen
Dim x As Integer
On Error GoTo ErrHandler
Application.ScreenUpdating = False
FilesToOpen = Application.GetOpenFilename _
(FileFilter:="Microsoft Excel Files (*.xls), *.xls", _
MultiSelect:=True, Title:="Files to Merge")
If TypeName(FilesToOpen) = "Boolean" Then
MsgBox "No Files were selected"
GoTo ExitHandler
End If
x = 1
While x <= UBound(FilesToOpen)
Workbooks.Open Filename:=FilesToOpen(x)
Sheets().Move After:=ThisWorkbook.Sheets _
(ThisWorkbook.Sheets.Count)
x = x + 1
Wend
ExitHandler:
Application.ScreenUpdating = True
Exit Sub
ErrHandler:
MsgBox Err.Description
Resume ExitHandler
End Sub
这是当前文件多表合并一个表
Sub 合并工作表()
'
For i = 1 To Worksheets.Count
m = Worksheets(i).Cells(65536, 1).End(xlUp).Row
Worksheets(i).Rows("1:" & m).Copy '拷贝当前单元格所在的区域
n = Cells(65536, 1).End(xlUp).Row '数据表的最大行
If Range("a1") <> "" Then n = n + 1
Range("A" & n).Select 'Select
ActiveSheet.Paste '在新工作表粘贴
Next
End Sub
按ALT +F11 ,插入模块,复制上面的代码,运行宏
热心网友
时间:2023-10-16 16:49
如果你对Access比较了解,建议用链接表,在Access中汇总。会减少大量重复工作。如果需要再将汇总结果导出到Excel。
热心网友
时间:2023-10-16 16:50
没办法
那就慢慢做呗,做不完加班还给加班费