|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
Sub sdyt()
On Error Resume Next
arr = Sheet1.Range("a2").CurrentRegion
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr)
For j = 8 To UBound(arr, 2) Step 3
If Val(arr(i, j)) > 1 Then
If Not d.exists(arr(i, 4)) Then
Set d(arr(i, 4)) = CreateObject("scripting.dictionary")
End If
d(arr(i, 4))(arr(1, j)) = d(arr(i, 4))(arr(1, j)) + Val(arr(i, j))
d(arr(i, 4))(Left(arr(1, j), 2)) = d(arr(i, 4))(Left(arr(1, j), 2)) + 1
d(arr(1, j)) = d(arr(1, j)) + Val(arr(i, j))
d(arr(1, j) & "人") = d(arr(1, j) & "人") + 1
End If
Next
Next
With Sheet2.Range("a2").CurrentRegion
.Offset(2, 2) = ""
arr = .Value
End With
For j = 2 To UBound(arr, 2) Step 2
For i = 3 To UBound(arr) - 1
If d(arr(i, 1)).exists((arr(1, j) & "分数")) Then
arr(i, j + 1) = Round(d(arr(i, 1))((arr(1, j) & "分数")) / d(arr(i, 1))((arr(1, j))), 2)
End If
Next
arr(UBound(arr), j + 1) = Round(d(arr(1, j) & "分数") / d(arr(1, j) & "分数人"), 2)
Next
Sheet2.Range("a1").CurrentRegion = arr
End Sub
|
评分
-
1
查看全部评分
-
|