|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- Set dcs = CreateObject("scripting.dictionary")
- 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
- 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
- With Worksheets("成绩")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(2, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a2").Resize(r, c)
- For i = 2 To UBound(arr)
- bj = Val(arr(i, 2))
- If Not d.exists(bj) Then
- Set d(bj) = CreateObject("scripting.dictionary")
- End If
- For j = 5 To UBound(arr, 2)
- If dcs.exists(arr(1, j)) Then
- If Len(arr(i, j)) <> 0 Then
- If Not d(bj).exists(arr(1, j)) Then
- ReDim brr(1 To 9)
- Else
- brr = d(bj)(arr(1, j))
- End If
- brr(1) = brr(1) + 1
- brr(2) = brr(2) + arr(i, j)
- If IsEmpty(brr(3)) Then
- brr(3) = arr(i, j)
- Else
- If brr(3) < arr(i, j) Then
- brr(3) = arr(i, j)
- End If
- End If
- If IsEmpty(brr(4)) Then
- brr(4) = arr(i, j)
- Else
- If brr(4) > arr(i, j) Then
- brr(4) = arr(i, j)
- End If
- End If
- If arr(i, j) >= dcs(arr(1, j))("及格") Then
- brr(5) = brr(5) + 1
- End If
- If arr(i, j) >= dcs(arr(1, j))("优良") Then
- brr(7) = brr(7) + 1
- End If
- d(bj)(arr(1, j)) = brr
- End If
- End If
- Next
- Next
- End With
- With Worksheets("分析表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(4, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a1").Resize(r, c)
- For i = 2 To 20 Step 18
- For k = 1 To 15
- bj = arr(i + k + 2, 1)
- If d.exists(bj) Then
- For j = 2 To 38 Step 9
- km = Replace(arr(i, j), " ", "")
- If d(bj).exists(km) Then
- brr = d(bj)(km)
- If brr(1) <> 0 Then
- brr(2) = Round(brr(2) / brr(1), 2)
- If Len(brr(5)) <> 0 Then
- brr(6) = Round(brr(5) / brr(1), 2)
- End If
- If Len(brr(7)) <> 0 Then
- brr(8) = Round(brr(7) / brr(1), 2)
- End If
- End If
- .Cells(i + k + 2, j).Resize(1, UBound(brr)) = brr
- End If
- Next
- End If
- Next
- Next
- End With
-
-
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|