これは
1~Nの整数をシャッフルして配列として返す関数。
コード
Function Shuffle(n As Long)
With New Dictionary
Do While .Count < n
.Item(WorksheetFunction.RandBetween(1, n)) = 0
DoEvents
Loop
Shuffle = .Keys
End With
End Function
テスト
Sub Test_Shuffle()
Dim arr
arr = Shuffle(13)
Debug.Print Join(arr)
End Sub
結果
9 12 8 7 5 10 6 1 11 4 2 3 13