|
Sub 汇总()
Application.ScreenUpdating = False
Dim d As Object
Dim ar As Variant, br As Variant
Dim i As Long
Dim arr()
ReDim arr(1 To 2000, 1 To 15)
f = Dir(ThisWorkbook.Path & "\*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
n = n + 1
ar = wb.Worksheets(1).Range("a1:f38")
wb.Close False
arr(n, 1) = n
arr(n, 2) = ar(2, 2)
arr(n, 4) = ar(2, 4)
arr(n, 5) = ar(7, 4)
arr(n, 6) = ar(4, 4)
arr(n, 7) = ar(4, 2)
arr(n, 8) = ar(5, 2)
arr(n, 9) = ar(6, 2)
arr(n, 10) = ar(5, 4)
arr(n, 11) = ar(10, 2)
arr(n, 13) = ar(7, 6)
End If
f = Dir
Loop
With Sheet1
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r > 3 Then .Range("a4:o" & r) = Empty
.Cells(4, 1).Resize(n, UBound(arr, 2)) = arr
End With
MsgBox "ok!"
Application.ScreenUpdating = True
End Sub
|
|