做个按钮指定该宏
Sub 生成0到9随机数()
Dim rng As Range, rng1 As Range
Set rng = Range("a1:a10")
rng.ClearContents
For Each rng1 In rng
Do
rng1 = Int(Rnd * 10)
Loop Until Application.WorksheetFunction.CountIf(rng, rng1) = 1
Next
End Sub
就会在a1:a10随机生成0--9的不重复随机数,点一次,更新一次 你稍微改下就好了!
用一列做辅助列,输入公式如下
=RAND() 下拉复制公式至数据最后一行
选中全部数据列以辅助列来进行排序
如不满意可以再次排序
完毕后删去辅助列