|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 成绩分析()
Application.ScreenUpdating = False
Dim ar As Variant
Dim i As Long, r As Long, rs As Long
Dim br()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Worksheets("原始数据")
r = .Cells(Rows.count, 1).End(xlUp).Row
ar = .Range("a2:i" & r)
End With
For i = 2 To UBound(ar)
If ar(i, 1) <> "" Then
s = Left(ar(i, 1), 3)
If Not d.exists(s) Then Set d(s) = CreateObject("scripting.dictionary")
d(s)(i) = ""
End If
Next i
ReDim br(1 To d.count, 1 To 24)
For Each k In d.keys
n = n + 1
br(n, 3) = k
lh = 4
For j = 3 To 5
For Each kk In d(k).keys
If ar(kk, j) <> "" Then
If IsNumeric(ar(kk, j)) Then
br(n, lh) = br(n, lh) + 1 ''参考人数
br(n, lh + 2) = br(n, lh + 2) + ar(kk, j) ''总分
If ar(kk, j) >= 60 Then
br(n, lh + 3) = br(n, lh + 3) + 1 ''及格人数
End If
If ar(kk, j) >= 90 Then
br(n, lh + 4) = br(n, lh + 4) + 1 ''优秀人数
End If
End If
Else
br(n, lh + 1) = br(n, lh + 1) + 1 ''缺考人数
End If
Next kk
lh = lh + 7
Next j
Next k
For i = 1 To n
For j = 6 To 20 Step 7
br(i, j) = Round(br(i, j) / br(i, j - 2), 2) ''平均分
br(i, j + 1) = Round(br(i, j + 1) / br(i, j - 2), 2) ''及格率
br(i, j + 2) = Round(br(i, j + 2) / br(i, j - 2), 2) ''优秀率
br(i, j + 3) = br(i, j) + br(i, j + 1) + br(i, j + 2) ''三率和
Next j
Next i
With Sheets("汇总")
.UsedRange.Offset(2).Borders.LineStyle = 0
.UsedRange.Offset(2) = Empty
.[a3].Resize(n, UBound(br, 2)) = br
.[a3].Resize(n, UBound(br, 2)).Borders.LineStyle = 1
End With
MsgBox "ok!"
End Sub
|
|