- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Application.ScreenUpdating = False
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- With Worksheets("成绩录入表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a3:q" & r)
- End With
- For j = 7 To 13 Step 2
- d.RemoveAll
- d1.RemoveAll
- sht = Left(arr(1, j), 2) & "统计"
- With Worksheets(sht)
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("h5:u" & r).ClearContents
- brr = .Range("a5:v" & r)
- For i = 1 To UBound(brr)
- If brr(i, 1) Like "*班" Then
- bj = Val(brr(i, 1))
- d(bj) = i
- End If
- Next
- End With
- For i = 2 To UBound(arr)
- bj = Val(Split(arr(i, 3), "(")(1))
- If d.exists(bj) Then
- m = d(bj)
- brr(m, 8) = brr(m, 8) + 1
- If IsNumeric(arr(i, j)) Then
- brr(m, 9) = brr(m, 9) + 1
- brr(m, 10) = brr(m, 10) + arr(i, j)
- If arr(i, j) >= 60 Then
- brr(m, 16) = brr(m, 16) + 1
- End If
- If arr(i, j) >= 80 Then
- brr(m, 18) = brr(m, 18) + 1
- End If
- If IsEmpty(brr(m, 20)) Then
- brr(m, 20) = arr(i, j)
- Else
- If brr(m, 20) < arr(i, j) Then
- brr(m, 20) = arr(i, j)
- End If
- End If
- If IsEmpty(brr(m, 21)) Then
- brr(m, 21) = arr(i, j)
- Else
- If brr(m, 21) > arr(i, j) Then
- brr(m, 21) = arr(i, j)
- End If
- End If
- End If
- End If
- Next
- For Each y In Array(8, 9, 10, 16, 18)
- For i = 1 To UBound(brr) - 1
- brr(UBound(brr), y) = brr(UBound(brr), y) + brr(i, y)
- Next
- Next
- brr(UBound(brr), 20) = Application.Max(Application.Index(brr, 0, 20))
- brr(UBound(brr), 21) = Application.Min(Application.Index(brr, 0, 21))
- For i = 1 To UBound(brr)
- If Len(brr(i, 9)) <> 0 And brr(i, 9) <> 0 Then
- brr(i, 11) = Round(brr(i, 10) / brr(i, 9), 2)
- brr(i, 17) = Round(brr(i, 16) / brr(i, 9), 2)
- brr(i, 19) = Round(brr(i, 18) / brr(i, 9), 2)
- End If
- Next
- For i = 1 To UBound(brr) - 1
- If Len(brr(i, 1)) <> 0 Then
- brr(i, 12) = brr(i, 11) - brr(UBound(brr), 11)
- d1(brr(i, 11)) = d1(brr(i, 11)) + 1
- End If
- Next
- kk = d1.keys
- nn = 1
- For k = 0 To UBound(kk)
- mm = Application.Large(kk, k + 1)
- ss = d1(mm)
- d1(mm) = nn
- nn = nn + ss
- Next
- For i = 1 To UBound(brr) - 1
- If Len(brr(i, 1)) <> 0 Then
- brr(i, 13) = d1(brr(i, 11))
- brr(i, 14) = brr(i, 7) - brr(i, 13)
- brr(i, 15) = brr(i, 12) - brr(i, 6)
- End If
- Next
- With Worksheets(sht)
- .Range("a5").Resize(UBound(brr), UBound(brr, 2)) = brr
- End With
- Next
- Application.ScreenUpdating = True
- MsgBox "成绩统计完毕!"
- End Sub
复制代码 |