|
Item(1)〜Item(4)の数字の重複を防ぎたいのですが、
どうすればよいかわかりません。
教えてください<(__)>
おねがいします。
Option Explicit
Option Base 1
Sub 乱数A1()
Dim a As Integer, b As Integer
Dim c As Integer, d As Integer, e As Integer
Dim GYO As Integer, Item() As String, X As Long
Cells.ClearContents
Randomize
a = 1 '乱数の下限
b = 5 '乱数の上限
c = 4 '乱数から取出す個数
d = 0 '空白のセル数
e = 1 '左からの列数
ReDim Item(c)
Item(1) = Int(Rnd * (b - a + 1) + 1)
Item(2) = Int(Rnd * (b - a + 1) + 1)
Item(3) = Int(Rnd * (b - a + 1) + 1)
Item(4) = Int(Rnd * (b - a + 1) + 1)
For X = 1 To c
GYO = X + d
Cells(GYO, e).Value = Item(X)
Next X
End Sub
|
|