|
附上代码
Sub 合计汇总()
Application.ScreenUpdating = False
Set d = CreateObject("Scripting.Dictionary")
lj = ThisWorkbook.Path & "\"
With Sheets("Sheet1")
arr = .Range("a6").CurrentRegion.Value
For i = 2 To UBound(arr)
d(arr(i, 5)) = i
Next
f = Dir(lj & "*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(lj & f, 0)
Set sht = wb.Worksheets(1)
brr = sht.UsedRange.Value
For i = 2 To UBound(brr)
If d.exists(brr(i, 7)) Then
he = 0
For j = 15 To 20
he = brr(i, j) + he
Next
arr(d(brr(i, 7)), 15) = he
End If
Next
wb.Close False
End If
f = Dir
Loop
.Range("a6").CurrentRegion = arr
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|