|
Sub 汇总()
Application.ScreenUpdating = False
Dim ar As Variant
Dim d As Object
Set d = CreateObject("scripting.dictionary")
lj = ThisWorkbook.Path & "\"
With ActiveSheet
.Range("d5:o30") = Empty
ar = .Range("a3:o30")
For i = 3 To UBound(ar)
If ar(i, 2) <> "" And ar(i, 3) <> "" Then
s = ar(i, 2) & "|" & ar(i, 3)
d(s) = i
End If
Next i
For j = 4 To UBound(ar, 2)
If ar(1, j) <> "" Then
ss = ar(1, j)
d(ss) = j
End If
Next j
f = Dir(lj & "*.xls*")
Do While f <> ""
If f <> ThisWorkbook.Name Then
Set wb = Workbooks.Open(lj & f, 0)
With wb.Worksheets(1)
r = .Cells(Rows.Count, 2).End(xlUp).Row
br = .Range("a3:l" & r)
rq = Day(Split(.[a2], "至")(0))
End With
wb.Close False
For i = 2 To UBound(br)
s = br(i, 2) & "|" & br(i, 3)
xh = d(s)
lh = d(rq)
If xh <> "" And lh <> "" Then
ar(xh, lh) = br(i, 12)
End If
Next i
End If
f = Dir
Loop
.Range("a3:o30") = ar
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
|