你怎么能以一个随机的顺序从列表中输入单词?

时间:2015-11-22 23:41:01

标签: excel vba excel-vba random shuffle

我在sheet2上有10个单词的列表,我需要创建一个按钮,将3个随机选择的单词从此列表放到另一个表单上。这需要重复10次。 即我需要点击按钮,它会出现类似的东西; 随机字随机字随机字 随机字随机字随机字 ......等等,直到完成10次。

到目前为止我有这个,但是其余的9行也被随机化了,它们与第一行中的字相同,有人可以帮忙吗?

For i = 1 To 10     'puts the list of 10 negative words into a list
myList(i) = Sheet2.Cells(i + 2, 1)
Next

Randomize

For i = 10 To 2 Step -1   'randomises the words in the list
    r = Int((i - 1 + 1) * Rnd + 1)
    temp = myList(i): myList(i) = myList(r): myList(r) = temp
    Next i


For k = 1 To 10
    For i = 1 To 3
    Sheet3.Cells(k + 1, i + 1) = myList(i)
    Next i
Next k

0 个答案:

没有答案