|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Set d = CreateObject("scripting.dictionary")
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- Set d3 = CreateObject("scripting.dictionary")
- Randomize (Timer)
- With Worksheets("上次成绩")
- .AutoFilterMode = False
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a1:p" & r)
- For i = 2 To UBound(arr)
- xm = arr(i, 2) & "+" & arr(i, 1)
- d(xm) = i
- Next
- For j = 3 To UBound(arr, 2)
- d1(arr(1, j)) = j
- Next
- r = .Cells(.Rows.Count, 28).End(xlUp).Row
- crr = .Range("ab1:ab" & r)
- For i = 2 To UBound(crr)
- d2(crr(i, 1)) = Empty
- Next
- End With
- With Worksheets("1")
- .AutoFilterMode = False
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- .Range("b2:b" & r).Font.ColorIndex = 0
- .Range("d2:l" & r).ClearContents
- brr = .Range("a1:m" & r)
- c = UBound(brr, 2)
- For j = 7 To UBound(brr, 2) - 1
- d2(Left(brr(1, j), 1)) = j
- Next
- For i = 2 To UBound(brr)
- xm = brr(i, 3) & "+" & brr(i, 2)
- If d.exists(xm) Then
- m = d(xm)
- For j = 4 To 6
- If d1.exists(brr(1, j)) Then
- n = d1(brr(1, j))
- brr(i, j) = arr(m, n)
- End If
- Next
- For k = 1 To Len(brr(i, c))
- km = Mid(brr(i, c), k, 1)
- If d2.exists(km) Then
- j = d2(km)
- If d1.exists(brr(1, j)) Then
- n = d1(brr(1, j))
- brr(i, j) = arr(m, n)
- End If
- End If
- Next
- End If
- For j = 4 To 6
- If Len(brr(i, j)) = 0 Then
- Select Case j
- Case 4
- brr(i, j) = 60 + Int(Rnd() * 26)
- Case 5
- brr(i, j) = 20 + Int(Rnd() * 31)
- Case 6
- brr(i, j) = 40 + Int(Rnd() * 26)
- End Select
- End If
- Next
- For k = 1 To Len(brr(i, c))
- km = Mid(brr(i, c), k, 1)
- If d2.exists(km) Then
- j = d2(km)
- If Len(brr(i, j)) = 0 Then
- Select Case km
- Case "物"
- brr(i, j) = 10 + Int(Rnd() * 21)
- Case "历"
- brr(i, j) = 30 + Int(Rnd() * 21)
- Case "化"
- brr(i, j) = 10 + Int(Rnd() * 21)
- Case "生"
- brr(i, j) = 30 + Int(Rnd() * 16)
- Case "政"
- brr(i, j) = 30 + Int(Rnd() * 21)
- Case "地"
- brr(i, j) = 30 + Int(Rnd() * 22)
- End Select
- End If
-
- End If
- Next
- If d2.exists(brr(i, 2)) Then
- brr(i, 6) = Empty
- End If
- Next
- .Range("a1:m" & r) = brr
- For i = 2 To UBound(brr)
- If Len(brr(i, 6)) = 0 Then
- .Cells(i, 2).Font.ColorIndex = 3
- End If
- Next
- End With
- End Sub
复制代码 |
|