试试
Sub Macro1()
Dim arr, brr(), d As Object, i&, j&, m&, s$, t$, v, u
Set d = CreateObject("scripting.dictionary")
With Sheets("成绩表")
arr = .Range("a3:n" & .Range("b65536").End(xlUp).Row)
End With
ReDim brr(1 To UBound(arr), 1 To 6)
For j = 5 To UBound(arr, 2)
v = arr(1, j) * 0.8
u = arr(1, j) * 0.6
t = arr(2, j)
For i = 3 To UBound(arr)
s = t & arr(i, 2)
If Not d.Exists(s) Then
m = m + 1
d(s) = m
brr(m, 1) = t
brr(m, 2) = arr(i, 2)
If Len(arr(i, j)) Then
brr(m, 3) = 1
brr(m, 4) = arr(i, j)
If arr(i, j) >= v Then brr(m, 6) = 1
If arr(i, j) >= u Then brr(m, 5) = 1
End If
Else
If Len(arr(i, j)) Then
brr(d(s), 3) = brr(d(s), 3) + 1
brr(d(s), 4) = brr(d(s), 4) + arr(i, j)
If arr(i, j) >= v Then brr(d(s), 6) = brr(d(s), 6) + 1
If arr(i, j) >= u Then brr(d(s), 5) = brr(d(s), 5) + 1
End If
End If
Next
Next
Range("C3:H" & Range("c65536").End(xlUp).Row + 3).ClearContents
Range("C3").Resize(m, 6) = brr
End Sub |