- Sub 汇总各班级每科平均分()
- Dim d, ar, br(), m, i, j
- Set d = CreateObject("Scripting.Dictionary")
- Range("H1:K100").ClearContents
- ar = Range("A1").CurrentRegion
- For i = 2 To UBound(ar)
- s = ar(i, 2)
- If d(s) = "" Then
- m = m + 1
- ReDim Preserve br(1 To 10, 1 To m)
- d(s) = m
- br(1, m) = ar(i, 2)
- For j = 3 To 5
- br(j + 2, m) = ar(i, j)
- br(j + 5, m) = 1
- br(j - 1, m) = br(j + 2, m) / br(j + 5, m)
- Next
- Else
- For j = 3 To 5
- br(j + 2, d(s)) = br(j + 2, d(s)) + ar(i, j)
- br(j + 5, d(s)) = br(j + 5, d(s)) + 1
- br(j - 1, d(s)) = br(j + 2, d(s)) / br(j + 5, d(s))
- Next
- End If
- Next
- [H2].Resize(m, 4) = Application.Transpose(br)
- Set d = Nothing
- End Sub
复制代码 |