|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
审核还没有通过:
Sub 新test()
t = Timer
Dim 成绩 As Integer
Set d = CreateObject("scripting.dictionary")
With Sheets("成绩表")
.[a1].CurrentRegion.Offset(1, 7).ClearContents
ar = .[a1].CurrentRegion.Resize(, 11)
'==========总分
For i = 2 To UBound(ar)
ar(i, 8) = ar(i, 5) + ar(i, 6) + ar(i, 7)
If Not d.exists(ar(i, 1) & ar(i, 2) & ar(i, 3)) Then '同校同年级同班[即班内]
Set d(ar(i, 1) & ar(i, 2) & ar(i, 3)) = CreateObject("scripting.dictionary")
End If
If Not d.exists(ar(i, 1) & ar(i, 2)) Then '同校同年级[即同校同级]
Set d(ar(i, 1) & ar(i, 2)) = CreateObject("scripting.dictionary")
End If
If Not d.exists(ar(i, 2)) Then '不分学校[不同校同级]
Set d(ar(i, 2)) = CreateObject("scripting.dictionary")
End If
d(ar(i, 2))(ar(i, 8)) = ""
d(ar(i, 1) & ar(i, 2) & ar(i, 3))(ar(i, 8)) = ""
d(ar(i, 1) & ar(i, 2))(ar(i, 8)) = ""
Next i
For i = 2 To UBound(ar)
成绩 = ar(i, 8)
ar(i, 9) = 排名(成绩, d(ar(i, 1) & ar(i, 2) & ar(i, 3)).keys)
ar(i, 10) = 排名(成绩, d(ar(i, 1) & ar(i, 2)).keys)
ar(i, 11) = 排名(成绩, d(ar(i, 2)).keys)
Next i
.[a1].Resize(UBound(ar), UBound(ar, 2)) = ar
End With
MsgBox "运行完毕,共计耗时:" & Format(Timer - t, "0.0000") & "秒"
End Sub
Function 排名(N1 As Integer, N2 As Variant)
For Each nn In N2
If nn >= N1 Then pm = pm + 1
Next
排名 = pm
End Function |
|