|
|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub test()
Dim i%, d1, d2, d3
Set d1 = CreateObject("scripting.dictionary")
Set d2 = CreateObject("scripting.dictionary")
Set d3 = CreateObject("scripting.dictionary")
For i = 2 To [i65536].End(3).Row
If Not d1.exists(Cells(i, "i").Value) Then
d1(Cells(i, "i").Value) = 1
Else
d1(Cells(i, "i").Value) = d1(Cells(i, "i").Value) + 1
End If
If Not d2.exists(Cells(i, "j").Value) Then
d2(Cells(i, "j").Value) = Cells(i, "k")
Else
d2(Cells(i, "j").Value) = d2(Cells(i, "j").Value) + Cells(i, "k")
End If
If Not d3.exists(Cells(i, "j").Value) Then
d3(Cells(i, "j").Value) = 1
Else
d3(Cells(i, "j").Value) = d3(Cells(i, "j").Value) + 1
End If
Next
Cells(2, 1).Resize(d1.Count, 1) = WorksheetFunction.Transpose(d1.keys)
Cells(2, 2).Resize(d1.Count, 1) = WorksheetFunction.Transpose(d1.items)
Cells(2, 4).Resize(d2.Count, 1) = WorksheetFunction.Transpose(d2.keys)
Cells(2, 5).Resize(d2.Count, 1) = WorksheetFunction.Transpose(d2.items)
Cells(2, 6).Resize(d3.Count, 1) = WorksheetFunction.Transpose(d3.items)
Set d1 = Nothing
Set d2 = Nothing
Set d3 = Nothing
End Sub
|
|