|
- Sub 统计()
- arr = Sheets("成绩表").UsedRange
- Set d = CreateObject("scripting.dictionary")
- For j = 5 To UBound(arr, 2) - 3
- For i = 3 To UBound(arr)
- s = arr(2, j) & "|" & arr(i, 2) '关键字科目+班级
- If d.exists(s) Then
- If arr(i, j) <> "" Then rs = rs + 1 '参考人数
- If arr(i, j) >= arr(1, j) * 0.6 Then hg = hg + 1 '合格人数
- If arr(i, j) >= arr(1, j) * 0.8 Then yx = yx + 1 '优秀人数
- zj = zj + arr(i, j) '班级单科总分
- d(s) = Array(zj, rs, hg, yx)
- Else
- rs = 0: hg = 0: yx = 0: zj = 0
- If arr(i, j) <> "" Then rs = 1
- If arr(i, j) >= arr(1, j) * 0.6 Then hg = 1
- If arr(i, j) >= arr(1, j) * 0.8 Then yx = 1
- zj = arr(i, j)
- d(s) = Array(zj, rs, hg, yx)
- End If
- Next i
- Next j
-
- ReDim brr(1 To d.Count, 1 To 6)
- For Each k In d.keys '循环字典,取出数据装入brr
- n = n + 1
- sp = Split(k, "|")
- brr(n, 1) = sp(0): brr(n, 2) = sp(1)
- brr(n, 3) = d(k)(1): brr(n, 4) = d(k)(0)
- brr(n, 5) = d(k)(2): brr(n, 6) = d(k)(3)
- Next k
-
- With Sheets("班科统计")
- .UsedRange.Offset(2).ClearContents '清空
- .[c3].Resize(n, 6) = brr '写入数据
- End With
-
- Set d = Nothing
- End Sub
复制代码 |
|