|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub 汇总()
Application.ScreenUpdating = False
Dim ar As Variant
Dim br()
ReDim br(1 To 500, 1 To 2)
lj = ThisWorkbook.Path & "\"
f = Dir(lj & "*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(lj & f, 0)
n = n + 1
br(n, 1) = Split(wb.Name, ".")(0)
With wb.Worksheets(1)
r = .Cells(Rows.Count, 6).End(xlUp).Row
ar = .Range("a1:f" & r)
End With
wb.Close False
For i = 3 To UBound(ar)
If Trim(ar(i, 1)) <> "合计" Then
If Trim(ar(i, 6)) <> "" Then
If IsNumeric(ar(i, 6)) Then
br(n, 2) = br(n, 2) + ar(i, 6)
End If
End If
End If
Next i
End If
f = Dir
Loop
With ActiveSheet
.[a1].CurrentRegion.Offset(1) = Empty
.[a2].Resize(n, 2) = br
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|