|
Sub 按钮1_Click()
Set d = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
arr = Sheets(1).UsedRange
For j = 2 To UBound(arr)
d(arr(j, 7)) = d(arr(j, 7)) + arr(j, 14)
Next j
With Sheets(2)
.UsedRange.Clear
.[a1] = "主料号"
.[b1] = "欠发数量"
.[a2].Resize(d.Count) = WorksheetFunction.Transpose(d.keys)
.[b2].Resize(d.Count) = WorksheetFunction.Transpose(d.items)
.Cells(d.Count + 2, 1) = "合计"
.Cells(d.Count + 2, 2) = WorksheetFunction.Sum(d.items)
End With
Application.ScreenUpdating = True
End Sub
|
|