|
Sub 汇总()
Application.ScreenUpdating = False
lj = ThisWorkbook.Path & "\明细表\"
f = Dir(lj & "*.xls*")
ReDim arr(1 To 10000, 1 To 5)
Do While f <> ""
Set wb = Workbooks.Open(lj & f, 0)
With wb.Worksheets("数据")
r = .Cells(Rows.Count, 1).End(xlUp).Row
ar = .Range("a1:j" & r)
End With
wb.Close False
For i = 11 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
n = n + 1
arr(n, 1) = ar(i, 2)
arr(n, 2) = ar(i, 3)
arr(n, 3) = ar(4, 8)
arr(n, 4) = ar(i, 10)
arr(n, 5) = ar(7, 3)
End If
Next i
f = Dir
Loop
With Sheet1
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(n, UBound(arr, 2)) = arr
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|