生成随机序列

利用vba生成8个随机数。

Sub rndSer()
    tempA = Array(0, 1, 2, 3, 4, 5, 6, 7)
    For i = 7 To 1 Step -1
        s = Int(Rnd() * (i + 1) + Second(Now())) Mod (i + 1)
        a = tempA(i)
        b = tempA(s)
        tempA(i) = b
        tempA(s) = a
    Next
    Range(Cells(1, 1), Cells(1, 8)).Resize = tempA
End Sub

猜你喜欢

转载自www.cnblogs.com/chenxiehan/p/12558774.html