|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 计算()
Dim ar As Variant
Dim d As Object, dc As Object
Set d = CreateObject("scripting.dictionary")
Set dc = CreateObject("scripting.dictionary")
With Sheets("sheet1")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "数据源为空!": End
.Range("e2:f" & r) = Empty
ar = .Range("a1:f" & r)
For i = 2 To UBound(ar)
If ar(i, 1) <> Empty And ar(i, 2) <> Empty And ar(i, 3) <> Empty Then
zd = ar(i, 1) & "|" & ar(i, 2) & "|" & ar(i, 3)
d(zd) = d(zd) + 1
dc(zd) = dc(zd) + ar(i, 4)
ar(i, 5) = d(zd)
ar(i, 6) = dc(zd)
End If
Next i
.Range("a1:f" & r) = ar
End With
MsgBox "ok!"
End Sub
|
|