|
- Sub test()
- Dim r%, i%
- Dim arr, brr, zrr()
- Dim d As Object
- Dim flg As Boolean
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Set djs = CreateObject("scripting.dictionary")
- With Worksheets("教师任课表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a1").Resize(r, c)
- For j = 2 To UBound(arr, 2)
- Set djs(arr(1, j)) = CreateObject("scripting.dictionary")
- For i = 2 To UBound(arr)
- djs(arr(1, j))(arr(i, 1)) = arr(i, j)
- Next
- Next
- End With
- With Worksheets("一分两率")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a1:a" & r)
- flg = False
- m = 0
- For i = 1 To UBound(arr)
- If arr(i, 1) = "班级" Then
- ReDim brr(1 To 2)
- brr(1) = i - 1
- brr(2) = i
- flg = True
- Else
- If flg Then
- brr(2) = i
- End If
- If arr(i, 1) = "合计" Then
- m = m + 1
- ReDim Preserve zrr(1 To m)
- zrr(m) = brr
- flg = False
- End If
- End If
- Next
- For k = 1 To UBound(zrr)
- brr = zrr(k)
- arr = .Range(.Cells(brr(1), 1), .Cells(brr(2), 9))
- km = Mid(arr(1, 1), 5, 2)
- If djs.exists(km) Then
- If Not d.exists(km) Then
- Set d(km) = CreateObject("scripting.dictionary")
- For i = 3 To UBound(arr) - 1
- If djs(km).exists(arr(i, 1)) Then
- js = djs(km)(arr(i, 1))
- If Not d(km).exists(js) Then
- ReDim crr(1 To 6)
- crr(1) = js
- crr(2) = arr(i, 1)
- Else
- crr = d(km)(js)
- crr(2) = crr(2) & "、" & arr(i, 1)
- End If
- crr(3) = crr(3) + arr(i, 3)
- crr(4) = crr(4) + arr(i, 5)
- crr(5) = crr(5) + arr(i, 7)
- crr(6) = crr(6) + arr(i, 2)
- d(km)(js) = crr
- End If
- Next
- End If
- End If
- Next
- End With
- With Worksheets("教师一分两率")
- .Cells.Clear
- .Range("e:f").NumberFormatLocal = "0.00%"
- With .Range("a:c,g:g")
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- For Each aa In d.keys
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- If r > 1 Then
- r = r + 2
- End If
- With .Cells(r, 1).Resize(1, 7)
- .Value = Array("科目", "姓名", "班别", "平均分", "全格率", "优秀率", "平均分排名")
- .HorizontalAlignment = xlCenter
- End With
- brr = Application.Transpose(Application.Transpose(d(aa).items))
- d1.RemoveAll
- For i = 1 To UBound(brr)
- brr(i, 3) = Round(brr(i, 3) / brr(i, 6), 2)
- brr(i, 4) = Round(brr(i, 4) / brr(i, 6), 4)
- brr(i, 5) = Round(brr(i, 5) / brr(i, 6), 4)
- d1(brr(i, 3)) = d1(brr(i, 3)) + 1
- Next
- nn = 1
- kk = d1.keys
- 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)
- brr(i, 6) = d1(brr(i, 3))
- Next
-
- .Cells(r + 1, 2).Resize(UBound(brr), UBound(brr, 2)) = brr
- With .Cells(r + 1, 1)
- .Value = aa
- .Resize(UBound(brr), 1).Merge
- End With
- With .Cells(r, 1).Resize(1 + UBound(brr), 7)
- .Borders.LineStyle = xlContinuous
- End With
- Next
- End With
-
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|