|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
三列任课复制成六列监考,然后运行程序后微调。
- Sub pske()
- Dim Arr, i&, j&, j1&, k&, Dic As Object, Dic1 As Object, Tmp
- Set Dic = CreateObject("Scripting.Dictionary")
- Set Dic1 = CreateObject("Scripting.Dictionary")
- Arr = [B1:H10]
- For j = 1 To 4
- Dic1.RemoveAll
- For i = 1 To 10
- k = 0
- Do
- Tmp = Arr(i, j)
- Dic(Tmp) = Dic(Tmp) + 1
- If Dic1.Exists(Arr(i, j)) Or Dic(Tmp) > 4 Then
- k = k + 1
- If k > 2 Then Arr(i, 7) = j & Tmp & Dic(Tmp): Exit Do
- For j1 = j To 6 - 1
- Arr(i, j1) = Arr(i, j1 + 1)
- Next j1: Arr(i, j1) = Tmp
- Dic(Tmp) = Dic(Tmp) - 1
- Else
- Dic1(Tmp) = "": Exit Do
- End If
- Loop
- Next i
- Next j
- [B1:H10] = Arr
- Set Dic1 = Nothing
- Set Dic = Nothing
- End Sub
复制代码 |
|