|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
只按照产品型号汇总数量:
Sub test()
Set d = CreateObject("scripting.dictionary")
l = 3
Do
l1 = Cells(l, 1).End(xlDown).Row + 1
If Cells(l1 - 1, 1) = "*" Or Cells(l1 - 1, 1) = "" Then Exit Do
l2 = Cells(l, 1).End(xlDown).End(xlDown).Row - 1
arr = Range("E" & l1 & ":G" & l2)
For i = 1 To UBound(arr)
d(arr(i, 1)) = d(arr(i, 1)) + arr(i, 3)
Next
m = d.Count
Range("E" & l1 & ":E" & l1 + m - 1) = WorksheetFunction.Transpose(d.keys)
Range("G" & l1 & ":G" & l1 + m - 1) = WorksheetFunction.Transpose(d.items)
If l2 > l1 + m - 1 Then
Rows(m + l1 & ":" & l2).Delete
End If
d.RemoveAll
l = l1 + m
Loop
End Sub |
评分
-
1
查看全部评分
-
|