|
- Sub 汇总()
- Dim strFileName As String, xlApp, xlBook, xlSheet
- Dim i As Integer, arr, temp(1 To 28, 1 To 10), j As Integer, k As Integer
- strFileName = Dir(ActiveWorkbook.Path & "")
- i = 1
- Set xlApp = CreateObject("Excel.Application")
- Application.ScreenUpdating = False
- Do While strFileName <> ""
- If strFileName <> ThisWorkbook.Name And InStr(strFileName, ".xls") > 0 Then
- Set xlBook = xlApp.Workbooks.Open(ActiveWorkbook.Path & "" & strFileName)
- For Each xlSheet In xlBook.Worksheets
- arr = xlSheet.Range("d6:m33")
- For j = 1 To 28
- For k = 1 To 10
- temp(j, k) = temp(j, k) + arr(j, k)
- Next
- Next
- Next
- xlApp.DisplayAlerts = False
- xlBook.Close
- With Sheets(i)
- .Range("d6:m33") = temp
- .Range("d2").Value = Split(strFileName, ".")(0)
- End With
- i = i + 1
- End If
- strFileName = Dir
- Loop
- xlApp.Quit
- Sheets(1).Range("d6:m33") = temp
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|