将这些文件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(sheet2:sheet13!B2) 把所有sheet的B2的和汇总。