|
Option Explicit
Sub TEST7()
Dim ar, br, i&, j&, dic As Object, vKey
Application.ScreenUpdating = False
Set dic = CreateObject("Scripting.Dictionary")
ar = [A1].CurrentRegion.Value
For i = 3 To UBound(ar)
dic(ar(i, 3)) = dic(ar(i, 3)) & " " & i
Next i
For Each vKey In dic.keys
br = Split(dic(vKey))
For j = 4 To UBound(ar, 2)
arrGetRnd1 br
For i = 1 To UBound(br)
ar(br(i), j) = i
Next i
Next j
Next
[A1].Resize(UBound(ar), UBound(ar, 2)) = ar
Set dic = Nothing
Application.ScreenUpdating = True
End Sub
Function arrGetRnd1(ByRef ar)
Dim xNum&, i&, n&, vTemp
Randomize
n = UBound(ar)
For i = 1 To UBound(ar)
xNum = Int((n - i + 1) * Rnd() + i)
vTemp = ar(xNum): ar(xNum) = ar(i): ar(i) = vTemp
Next
End Function
|
评分
-
1
查看全部评分
-
|