|
- Sub Macro1()
- Dim wb As Workbook, mypath$, wj, n&, x&
- mypath = ThisWorkbook.Path & ""
- wj = Dir(mypath & "*.xls")
- n = 5
- Application.ScreenUpdating = False
- [a5:f20000].Clear
- Do While wj <> ""
- If wj <> ThisWorkbook.Name Then
- Set wb = GetObject(mypath & wj)
- dw = Replace(wb.Name, ".xls", "")
- With wb.Sheets(1)
- x = .Range("a5").End(xlDown).Row
- Cells(n, 1).Resize(x - 4) = dw
- .Range(.Cells(5, 1), .Cells(x, 6)).Copy Cells(n, 2)
- End With
- n = Range("b65536").End(xlUp).Row + 1
- wb.Close 0
- End If
- wj = Dir
- Loop
- Cells(n, 2) = "合计"
- For i = 3 To 5
- Cells(n, i) = Application.Sum(Cells(5, i).Resize(n - 5))
- Next
- With Range("a5:f" & n).Borders()
- .LineStyle = xlContinuous
- .Weight = xlThin
- End With
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|