|
发表于 2013-6-28 09:00
|
显示全部楼层
本楼为最佳答案
- Sub 汇总()
- Application.ScreenUpdating = False
- Dim lj As String, m, n
- Dim dirname As String
- Dim nm As String
- Dim wb As Workbook
- Dim i As Integer
- On Error Resume Next
- With Application
- .ScreenUpdating = False
- .DisplayAlerts = False
- .EnableEvents = False
- .Calculation = xlCalculationManual
- End With
- lj = ThisWorkbook.Path
- nm = ThisWorkbook.Name
- dirname = Dir(lj & "\*.xlsx")
- Cells.Clear
- Do While dirname <> ""
- If dirname <> nm Then
- Set wb = Workbooks.Open(Filename:=lj & "" & dirname, UpdateLinks:=False, ReadOnly:=True)
- If Not wb Is Nothing Then
- With wb
- If Len(.Sheets("开始").Name) = 0 Then
- Else
- i = .Sheets("开始").Range("A65536").End(xlUp).Row
- ThisWorkbook.Sheets("统计表").Cells(m, 1) = .Sheets("开始").Cells(2, 1).Value
- ThisWorkbook.Sheets("统计表").Cells(n, 2) = .Sheets("开始").Cells(2, 1).Value
- End If
- .Close False
- End With
- Set wb = Nothing
- End If
- End If
- dirname = Dir
- Loop
- With Application
- .ScreenUpdating = True
- .DisplayAlerts = True
- .EnableEvents = True
- .Calculation = xlCalculationAutomatic
- End With
- MsgBox "OK"
- End Sub
复制代码 |
|