|
Sub 汇总()
Application.ScreenUpdating = False
Set sh = ThisWorkbook.Worksheets(1)
r = sh.Cells(Rows.Count, 2).End(xlUp).Row
sh.Range("b5:i" & r) = Empty
ar = sh.Range("a1:i" & r)
f = Dir(ThisWorkbook.Path & "\*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name And f <> "模板" Then
Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & f, 0)
With wb.Worksheets(1)
rs = .Cells(Rows.Count, 2).End(xlUp).Row
br = .Range("a1:i" & rs)
End With
For i = 5 To UBound(br)
If Trim(br(i, 2)) <> "" Then
For j = 2 To UBound(br, 2)
ar(i, j) = br(i, j)
Next j
End If
Next i
wb.Close False
End If
f = Dir
Loop
sh.Range("a1:i" & r) = ar
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|