|
Option Explicit
Sub test2() '是这个效果吧?
Dim d As Object, ar, br, i&, j&, x&, y&, s$, t$
Set d = CreateObject("Scripting.Dictionary")
With Sheets("汇总").[a1].CurrentRegion
.Offset(1, 1).ClearContents
ar = .Value
End With
For i = 2 To UBound(ar)
s = ar(i, 1)
If Len(s) Then d(s) = i
Next
For j = 2 To UBound(ar, 2)
t = ar(1, j)
If Len(t) Then d(t) = j
Next
With Sheets("生产日报表")
br = .Range("e1:k" & .Cells(.Rows.Count, 5).End(xlUp).Row)
End With
For i = 2 To UBound(br)
s = br(i, 4)
t = br(i, 1)
If d.Exists(s) And d.Exists(t) Then
y = d(s)
x = d(t)
ar(y, x) = ar(y, x) + Val(br(i, 7))
End If
Next
Sheets("汇总").[a1].Resize(UBound(ar), UBound(ar, 2)) = ar
Set d = Nothing
End Sub |
评分
-
3
查看全部评分
-
|