总成绩加了权重,便于不并列排名
- Sub test()
- r = [a65536].End(xlUp).Row
- Range("h3", Cells(r, "j")).ClearContents
- cj = Range("c3", Cells(r, "g"))
- zf = Range("h3", Cells(r, "h"))
- jm = Range("i3", Cells(r, "i"))
- '----------总分:加成绩权重,便于不重复排名---------
- For i = 3 To r
- For j = 1 To 5
- zf(i - 2, 1) = zf(i - 2, 1) + cj(i - 2, j)
- Next
- zf(i - 2, 1) = zf(i - 2, 1) + cj(i - 2, 2) / zf(i - 2, 1) / 100 + Rnd() / 10000
- Next
- Range("h3", Cells(r, "h")) = zf
- '-----------年级成绩排名------------
- For i = 3 To r
- jm(i - 2, 1) = Application.WorksheetFunction.Rank(zf(i - 2, 1), Range("h3", Cells(r, "h")), 0)
- Next
- Range("i3", Cells(r, "i")) = jm
- '----------各班级排名------------
- s = [a3] & ",3;"
- For i = 3 To r
- If InStr(s, Cells(i, 1)) = 0 Then
- s = s & Cells(i, 1) & "," & i & ";"
- End If
- Next
- s = s & "," & r + 1
- bj = Split(s, ";")
- For i = 0 To UBound(bj) - 1
- a = Split(bj(i), ",")(1)
- b = Split(bj(i + 1), ",")(1) - 1
- c = Range(Cells(a, "h"), Cells(b, "h"))
- bm = Range(Cells(a, "j"), Cells(b, "j"))
- For j = a To b
- bm(j - a + 1, 1) = Application.WorksheetFunction.Rank(c(j - a + 1, 1), Range(Cells(a, "h"), Cells(b, "h")), 0)
- Next
- Range(Cells(a, "j"), Cells(b, "j")) = bm
- Next
- '------修正总成绩------
- For i = 3 To r
- zf(i - 2, 1) = Round(zf(i - 2, 1), 0)
- Next
- Range("h3", Cells(r, "h")) = zf
- End Sub
复制代码 |