Sub pldrwb1007() Dim myFs As FileSearch Dim myPath As String, Filename$ Dim i As Long, n As Long Dim Sht1 As Worksheet, sh As Worksheet Dim wb1 As Workbook Dim wb As Workbook Dim aa, nm$, nm1$, m, arr, r1, col1% Application.ScreenUpdating = False Set wb1 = ThisWorkbook Set myFs = Application.FileSearch myPath = ThisWorkbook.Path With myFs .NewSearch .LookIn = myPath .FileType = msoFileTypeNoteItem .Filename = "*.xls" If .Execute(SortBy:=msoSortByFileName) > 0 Then n = .FoundFiles.Count col1 = 2 ReDim myfile(1 To n) As String For i = 1 To n myfile(i) = .FoundFiles(i) Workbooks.Open myfile(i) Set wb = ActiveWorkbook m = [a65536].End(xlUp).Row Cells(m + 1, 1).Formula = "=sum(r2c:r[-1]c)" Cells(m + 1, 2).Formula = "=sum(r2c:r[-1]c)" [c2].formua = "=rc[-2]+rc[-1]" [c2].AutoFill Range("c2:c" & m + 1) If wb <> wb1 Then wb.Close savechanges:=True Set wb = Nothing End If Next Else MsgBox "该文件夹里没有任何文件" End If End With Set myFs = Nothing Application.ScreenUpdating = True End Sub