|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
三率计算
- Sub test2()
- Dim r%, i%
- Dim arr, brr, zrr()
- Dim d As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- With Worksheets("起点三率计算")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- .Range("d2").Resize(r - 1, c - 3).ClearContents
- brr = .Range("a2").Resize(r - 1, c)
- xx = ""
- m = 0
- For i = 1 To UBound(brr)
- xm = brr(i, 1) & "+" & brr(i, 2) & "+" & brr(i, 3)
- d(xm) = i
- If brr(i, 1) & "+" & brr(i, 2) <> xx Then
- m = m + 1
- ReDim Preserve zrr(1 To 2, 1 To m)
- zrr(1, m) = i
- zrr(2, m) = i
- xx = brr(i, 1) & "+" & brr(i, 2)
- Else
- zrr(2, m) = i
- End If
- Next
- End With
- With Worksheets("起点成绩")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:h" & r)
- End With
- For i = 1 To UBound(arr)
- xm = arr(i, 1) & "+" & arr(i, 2) & "+" & arr(i, 3)
- If d.exists(xm) Then
- m = d(xm)
- For j = 6 To 8
- n = j * 15 - 86
- If Len(arr(i, j)) <> 0 Then
- brr(m, n) = brr(m, n) + 1
- brr(m, n + 1) = brr(m, n + 1) + arr(i, j)
- If arr(i, 2) <= 5 Then
- If arr(i, j) >= 90 Then
- brr(m, n + 6) = brr(m, n + 6) + 1
- End If
- If arr(i, j) >= 60 Then
- brr(m, n + 11) = brr(m, n + 11) + 1
- End If
- Else
- Select Case j
- Case 6
- If arr(i, 3) Mod 2 = 1 Then
- If arr(i, j) >= 85 Then
- brr(m, n + 6) = brr(m, n + 6) + 1
- End If
- Else
- If arr(i, j) >= 80 Then
- brr(m, n + 6) = brr(m, n + 6) + 1
- End If
- End If
- If arr(i, j) >= 60 Then
- brr(m, n + 11) = brr(m, n + 11) + 1
- End If
- Case 7
- If arr(i, 3) Mod 2 = 1 Then
- If arr(i, j) >= 90 Then
- brr(m, n + 6) = brr(m, n + 6) + 1
- End If
- Else
- If arr(i, j) >= 80 Then
- brr(m, n + 6) = brr(m, n + 6) + 1
- End If
- End If
- If arr(i, j) >= 60 Then
- brr(m, n + 11) = brr(m, n + 11) + 1
- End If
- Case 8
- If arr(i, 3) Mod 2 = 1 Then
- If arr(i, j) >= 27 Then
- brr(m, n + 6) = brr(m, n + 6) + 1
- End If
- Else
- If arr(i, j) >= 24 Then
- brr(m, n + 6) = brr(m, n + 6) + 1
- End If
- End If
- If arr(i, j) >= 18 Then
- brr(m, n + 11) = brr(m, n + 11) + 1
- End If
- End Select
- End If
- End If
- Next
- End If
- Next
- For q = 1 To UBound(zrr, 2)
- ReDim crr(1 To UBound(brr, 2))
- For i = zrr(1, q) To zrr(2, q)
- For j = 4 To UBound(brr, 2)
- crr(j) = crr(j) + brr(i, j)
- Next
- Next
- For j = 4 To UBound(brr, 2) Step 15
- If Len(crr(j)) <> 0 And crr(j) <> 0 Then
- crr(j + 1) = Round(crr(j + 1) / crr(j), 2)
- crr(j + 6) = Round(crr(j + 6) / crr(j), 4)
- crr(j + 11) = Round(crr(j + 11) / crr(j), 4)
- End If
- Next
- For i = zrr(1, q) To zrr(2, q)
- For j = 4 To UBound(brr, 2) Step 15
- If Len(brr(i, j)) <> 0 And brr(i, j) <> 0 Then
- brr(i, j + 1) = Round(brr(i, j + 1) / brr(i, j), 2)
- brr(i, j + 6) = Round(brr(i, j + 6) / brr(i, j), 4)
- brr(i, j + 11) = Round(brr(i, j + 11) / brr(i, j), 4)
- End If
- Next
- Next
- For i = zrr(1, q) To zrr(2, q)
- For j = 4 To UBound(brr, 2) Step 15
- brr(i, j) = crr(j + 1)
- brr(i, j + 5) = crr(j + 6)
- brr(i, j + 10) = crr(j + 11)
- brr(i, j + 2) = Round(brr(i, j + 1) - brr(i, j), 2)
- brr(i, j + 7) = Round(brr(i, j + 6) - brr(i, j + 5), 2)
- brr(i, j + 12) = Round(brr(i, j + 11) - brr(i, j + 10), 2)
- Next
- Next
- For j = 4 To UBound(brr, 2) Step 15
- For y = 2 To 12 Step 5
- d1.RemoveAll
- If brr(zrr(1, q), 2) < 5 Then
- For i = zrr(1, q) To zrr(2, q)
- If Len(brr(i, j + y)) <> 0 Then
- d1(brr(i, j + y)) = d1(brr(i, j + y)) + 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 i = zrr(1, q) To zrr(2, q)
- If Len(brr(i, j + y)) <> 0 Then
- brr(i, j + y + 1) = d1(brr(i, j + y))
- brr(i, j + y + 2) = zrr(2, q) - zrr(1, q) + 2 - brr(i, j + y + 1)
- End If
- Next
- Else
- For i = zrr(1, q) To zrr(2, q)
- If Len(brr(i, j + y)) <> 0 Then
- w = brr(i, 2) Mod 2
- If Not d1.exists(w) Then
- Set d1(w) = CreateObject("scripting.dictionary")
- End If
- d1(w)(brr(i, j + y)) = d1(w)(brr(i, j + y)) + 1
- End If
- Next
- For Each bb In d1.keys
- nn = 1
- kk = d1(bb).keys
- For k = 0 To UBound(kk)
- mm = Application.Large(kk, k + 1)
- ss = d1(bb)(mm)
- d1(bb)(mm) = nn
- nn = nn + ss
- Next
- Next
- For i = zrr(1, q) To zrr(2, q)
- If Len(brr(i, j + y)) <> 0 Then
- w = brr(i, 2) Mod 2
- brr(i, j + y + 1) = d1(w)(brr(i, j + y))
- End If
- Next
- End If
- Next
- Next
- Next
- With Worksheets("起点三率计算")
- .Range("a2").Resize(UBound(brr), UBound(brr, 2)) = brr
- End With
- End Sub
复制代码 |
评分
-
2
查看全部评分
-
|