|
按年级的。。。。。- Sub 按年级()
- Dim N
- r = [c65536].End(3).Row
- arr = [a1].CurrentRegion
- brr = arr
- N = UBound(arr) - 1 '年级总人数
- yx = Round(N * 0.3, 0) '按比例优秀人数
- lh = Round(N * 0.4, 0) '按比例良好人数
- For j = 4 To 12
- If j <> 7 And j <> 8 Then '物理、化学无数据
- xyx = 0: xlh = 0 '总优秀人数、总良好人数
- For i = 2 To N
- Set xrng = Range(Cells(2, j), Cells(N + 1, j))
- xrank = Application.WorksheetFunction.Rank(arr(i, j), xrng) '名次
- If xrank <= yx And xyx < yx Then '如果名次为优秀,总优秀人数小于按比例优秀人数
- brr(i, j) = "优秀"
- xyx = xyx + 1
- '如果名次为优秀,总优秀人数等于按比例优秀人数,或者名次为良好,总良好人数小于按比例良好人数
- ElseIf (xrank <= yx And xyx = yx) Or (xrank <= yx + lh And xlh < lh) Then
- brr(i, j) = "良好"
- xlh = xlh + 1
- Else
- brr(i, j) = "合格"
- End If
- Next
- End If
- Next
- Sheet2.[a1].Resize(N + 1, 12) = brr
- Sheet2.Activate
- End Sub
复制代码 |
|