如何将不同Excel表格的同一个人数据自动汇总在一起

如题所述

第1个回答  推荐于2017-11-25
将这些文件copy到一个文件夹(只有这些Excel,且若打开某一文件,数据就能看见——即不用点其他sheet),建一新Excel,也存到该文件夹。仅打开该新Excel,按Alt+F11,左边窗口右键点,插入模块,在右边窗口粘贴如下代码:

Sub Find()
Application.ScreenUpdating = False
Dim MyDir As String
MyDir = ThisWorkbook.Path & "\"
ChDrive Left(MyDir, 1) 'find all the excel files
ChDir MyDir
Match = Dir$("")
Do
If Not LCase(Match) = LCase(ThisWorkbook.Name) Then
Workbooks.Open Match, 0 'open
ActiveSheet.Copy Before:=ThisWorkbook.Sheets(1) 'copy sheet
Windows(Match).Activate
ActiveWindow.Close
Match = Dir$
End If
Loop Until Len(Match) = 0
Application.ScreenUpdating = True
End Sub

按F5执行此宏,文件copy完成。

然后可以用sum(sheet12:sheet30!A1)汇总了。
如果数据只有几列的话,可以直接用宏copy到一张工作表中。本回答被网友采纳
相似回答