我有一个1000x3个字的excel文件。我在这里写了5行作为例子。
Target choice1 choice2 choice3
booklet criquet nutmeg luciole
argoman border phobie liom
mouche libellule taplet luciole
abrot guêpe terrier greeca然而,我知道目前choice2中的所有单词都是正确答案,我想使用天平办公室随机混合选项1和选项2和选项3的位置,如下:
Target choice1 choice2 choice3
booklet nutmeg criquet luciole
argoman phobie liom border
mouche taplet libellule luciole
abrot terrier guêpe greeca我刚接触excel,我不知道如何使用它。请建议我如何做,在此之前,我感谢所有的意见。
发布于 2017-03-15 03:31:11
抱歉,回复晚了。
您可以使用类似以下内容:
Sub MixTheValues()
Dim x, y, r
Dim Words As New Collection
For x = 2 To Cells(Rows.CountLarge, "B").End(xlUp).Row
For y = 2 To 4
Words.Add (Cells(x, y).Value)
Next y
For y = 2 To 4
r = Int(Words.Count * Rnd + 1)
Cells(x, y).Value = Words(r)
Words.Remove (r)
Next y
Next x
End Subx从第2行开始,一直到最后一行。
y定义要使用的列(在本例中为2 to 4或B to D
请注意,这会打乱答案,但因为它是完全随机的,所以其中一些可能根本不会移动。
结果:

https://stackoverflow.com/questions/42792775
复制相似问题