- Sub demo()
- Application.ScreenUpdating = False
- Dim iPath As String, iFile As String, i As Integer
- Dim wb As Workbook, arr(1 To 100, 1 To 2)
- iPath = ThisWorkbook.Path & ""
- iFile = Dir(iPath & "*.xlsx")
- Do While iFile <> ""
- If iFile <> ThisWorkbook.Name Then
- Set wb = Workbooks.Open(iPath & iFile)
- i = i + 1
- arr(i, 1) = Replace(wb.Name, ".xlsx", "")
- arr(i, 2) = wb.Sheets(1).Cells.Find(What:="合计").Offset(0, 1).Value
- wb.Close False
- End If
- iFile = Dir
- Loop
- ThisWorkbook.Sheets(1).Cells(2, 1).Resize(100, 2) = arr
- Application.ScreenUpdating = True
- End Sub
复制代码 |