|
- Sub cjbgd(ByVal xk As String, ByVal nj As String)
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- Set dcs = 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 dcs(arr(1, j)) = CreateObject("scripting.dictionary")
- For i = 2 To UBound(arr)
- dcs(arr(1, j))(arr(i, 1)) = arr(i, j)
- Next
- Next
- End With
- With Worksheets("原始成绩")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(2, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a2").Resize(r - 1, c)
- End With
- ReDim brr(1 To UBound(arr), 1 To 2)
- For j = 3 To UBound(arr, 2)
- If arr(1, j) = xk Then
- j0 = j
- End If
- Next
- For i = 2 To UBound(arr)
- If Not d2.exists(arr(i, 2)) Then
- Set d2(arr(i, 2)) = CreateObject("scripting.dictionary")
- End If
- If Len(arr(i, j0)) <> 0 Then
- brr(1, 1) = brr(1, 1) + 1
- d1(arr(i, j0)) = d1(arr(i, j0)) + 1
- d2(arr(i, 2))(arr(i, j0)) = d2(arr(i, 2))(arr(i, j0)) + 1
- End If
- 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 Each aa In d2.keys
- nn = 1
- kk = d2(aa).keys
- For k = 0 To UBound(kk)
- mm = Application.Large(kk, k + 1)
- ss = d2(aa)(mm)
- d2(aa)(mm) = nn
- nn = nn + ss
- Next
- Next
- For i = 2 To UBound(arr)
- If Len(arr(i, j0)) <> 0 Then
- brr(i, 1) = d1(arr(i, j0))
- brr(i, 2) = d2(arr(i, 2))(arr(i, j0))
- End If
- Next
- ReDim drr(1 To 20, 1 To 1)
-
- ReDim crr(1 To 35, 1 To 9)
- s = 0
- m = 1
- n = 1
- For i = 2 To UBound(arr)
- If arr(i, 2) = nj Then
- s = s + 1
- crr(m, n) = arr(i, 1)
- crr(m, n + 1) = arr(i, j0)
- crr(m, n + 2) = brr(i, 1)
- crr(m, n + 3) = brr(i, 2)
- m = m + 1
- If m > 35 Then
- m = 1
- n = 6
- End If
-
- drr(1, 1) = drr(1, 1) + arr(i, j0)
- If arr(i, j0) >= dcs(xk)("优秀") Then
- drr(4, 1) = drr(4, 1) + 1
- End If
- If arr(i, j0) >= dcs(xk)("优良") Then
- drr(6, 1) = drr(6, 1) + 1
- End If
- If arr(i, j0) >= dcs(xk)("及格") Then
- drr(8, 1) = drr(8, 1) + 1
- Else
- drr(10, 1) = drr(10, 1) + 1
- End If
-
- If brr(i, 1) <= Application.Round(brr(1, 1) * 0.1, 0) Then
- drr(13, 1) = drr(13, 1) + 1
- End If
- If brr(i, 1) <= Application.Round(brr(1, 1) * 0.3, 0) Then
- drr(15, 1) = drr(15, 1) + 1
- End If
- If brr(i, 1) <= Application.Round(brr(1, 1) * 0.6, 0) Then
- drr(17, 1) = drr(17, 1) + 1
- End If
- If brr(i, 1) > Application.Round(brr(1, 1) * 0.9, 0) Then
- drr(19, 1) = drr(19, 1) + 1
- End If
-
- End If
- Next
- If s <> 0 Then
- drr(1, 1) = Application.Round(drr(1, 1) / s, 2)
- drr(5, 1) = Application.Round(drr(4, 1) / s, 4)
- drr(7, 1) = Application.Round(drr(6, 1) / s, 4)
- drr(9, 1) = Application.Round(drr(8, 1) / s, 4)
- drr(11, 1) = Application.Round(drr(10, 1) / s, 4)
- drr(14, 1) = Application.Round(drr(13, 1) / s, 4)
- drr(16, 1) = Application.Round(drr(15, 1) / s, 4)
- drr(18, 1) = Application.Round(drr(17, 1) / s, 4)
- drr(20, 1) = Application.Round(drr(19, 1) / s, 4)
- End If
- On Error Resume Next
- Set ws = Worksheets("成绩报告单")
- If Err Then
- Set ws = Worksheets.Add(after:=Worksheets(Worksheets.Count))
- ws.Name = "成绩报告单"
- End If
- On Error GoTo 0
- With ws
- .Cells.Clear
- With .Range("a1")
- .Value = Worksheets("原始成绩").Range("a1")
- .Resize(1, 12).Merge
- With .Font
- .Name = "微软雅黑"
- .Size = 16
- End With
- End With
- .Range("a2:d2") = Array("姓名", xk, xk & "年名", xk & "班名")
- .Range("f2:i2") = Array("姓名", xk, xk & "年名", xk & "班名")
- With .Range("a3").Resize(UBound(crr), UBound(crr, 2))
- .Value = crr
- End With
- For Each aa In Array("a2", "f2")
- With .Range(aa).Resize(1 + UBound(crr), 4)
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 10
- End With
- End With
- Next
- .Range("k2:k4") = Application.Transpose(Array("班 级", "参考人数", "学 科"))
- .Range("l2:l4") = Application.Transpose(Array(nj, s, xk))
- With .Range("k2:l4")
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 10
- End With
- End With
- With .Range("k6")
- .Resize(1, 2).Merge
- .Value = "学科成绩分析"
- With .Font
- .Name = "微软雅黑"
- .Size = 10
- End With
- End With
- .Range("k7:k26") = [{"平均分";"平均率";"";"优秀数";"优秀率";"优良数";"优良率";"及格数";"及格率";"低差数";"低差率";"";"A类生数";"A类比率";"B类生数";"B类生率";"C类生数";"C类生率";"D类生数";"D类生率"}]
- .Range("l7").Resize(UBound(drr), UBound(drr, 2)) = drr
- For i = 11 To 17 Step 2
- .Cells(i, 12).NumberFormatLocal = "0.00%"
- Next
- For i = 20 To 26 Step 2
- .Cells(i, 12).NumberFormatLocal = "0.00%"
- Next
- With .Range("k7:l26")
- .Borders.LineStyle = xlContinuous
- With .Font
- .Name = "微软雅黑"
- .Size = 10
- End With
- End With
- With .UsedRange
- .HorizontalAlignment = xlCenter
- .VerticalAlignment = xlCenter
- End With
- End With
- End Sub
复制代码 |
|