|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
复习一下字典存入数组
Sub byPeteryhr()
Dim d As Object, arr, brr(), i&
Set d = CreateObject("scripting.dictionary")
arr = Range("a1:b" & Cells(Rows.Count, 1).End(xlUp).Row)
For i = 2 To UBound(arr)
If d.exists(arr(i, 1)) Then
d(arr(i, 1)) = Array(d(arr(i, 1))(0) + 1, d(arr(i, 1))(1) + arr(i, 2))
Else
d(arr(i, 1)) = Array(1, arr(i, 2))
End If
Next
ReDim brr(1 To d.Count, 1 To 3)
For i = 1 To d.Count
brr(i, 1) = d.Keys()(i - 1)
brr(i, 2) = d.items()(i - 1)(0)
brr(i, 3) = d.items()(i - 1)(1)
Next
With Sheet1.[d2]
.NumberFormat = "@"
.CurrentRegion.Offset(1).ClearContents
.Resize(UBound(brr), UBound(brr, 2)) = brr
End With
Set d = Nothing
MsgBox "合 计 成 绩 统 计 完 成。"
End Sub |
|