|
原来的“提取”“计算”的控件在右侧的时候,可以计算正确结果,现在放到第一行里时就无法计算了。
Sub 汇总期末()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("合并工作底稿-期末")
.[a1].CurrentRegion.Offset(3, 1) = Empty
ar = .[a1].CurrentRegion
For i = 3 To UBound(ar)
If Trim(ar(i, 1)) <> "" Then
d(Trim(ar(i, 1))) = i
End If
Next i
For j = 2 To UBound(ar, 2)
If Trim(ar(1, j)) <> "" Then
d(Trim(ar(1, j))) = j
End If
Next j
For Each sh In Sheets
If sh.Name <> "合并工作底稿-期末" And sh.Name <> "抵消明细" Then
r = sh.Cells(Rows.Count, 1).End(xlUp).Row
br = sh.Range("a3:m" & r)
y = d(sh.Name)
For i = 1 To UBound(br)
If Trim(br(i, 1)) <> "" Then
x = d(Trim(br(i, 1)))
If x <> "" And y <> "" Then
ar(x, y) = ar(x, y) + br(i, 4)
End If
End If
Next i
End If
Next sh
.[a1].CurrentRegion = ar
End With
MsgBox "ok!"
End Sub
|
|