发布网友 发布时间:2022-04-24 09:30
共1个回答
热心网友 时间:2023-10-09 11:22
'你会用VBA吗?这个必须用VBA来完成!不知你是否会用!
'1.进入EXCEL表格,按ALT+F11组合键入VBA编辑器
'2.插入一个模块,复制以下代码
'3.回到表格页面文件,插入一个按钮,为其指定该宏,然后每点击一次则会自动排列一次
Sub 舒尔特测试()
Dim t, i, seed, sjs(25)
seed = 16525 * Second(Now()) + 1
For t = 1 To 25
Randomize (seed)
sjs(t) = Int(25 * Rnd) + 1
For i = 1 To (t - 1)
If sjs(t) = sjs(i) Then
sjs(t) = Int(25 * Rnd) + 1
i = 0
End If
seed = seed + 1
Next i
Next t
For t = 1 To 5
Cells(1, t).Value = sjs(t)
Next t
For t = 6 To 10
Cells(2, t - 5).Value = sjs(t)
Next t
For t = 11 To 15
Cells(3, t - 10).Value = sjs(t)
Next t
For t = 16 To 20
Cells(4, t - 15).Value = sjs(t)
Next t
For t = 21 To 25
Cells(5, t - 20).Value = sjs(t)
Next t
End Sub
'以上代码完全测试通过,5X5格式,你可以自己修成你想要的任何格式!