如何用excel的vba做一个抽签命令,要能够控制它最后停在哪,即抽签结果

来源:百度知道 编辑:UC知道 时间:2024/09/24 13:42:29
按开始按钮后即启动,依次抽到9,8,。。。1,0.类似于倒计时。谢谢大虾们,急呀

问题描述得不清不楚的话 再急人家也不知道
这是我做的 不知道对你有用没
Sub 开始抽签()

For i = 9 To 0 Step -1
wt = 1

Do While wt > 0.1
ra = Int(Rnd() * 10)
Select Case ra
Case 0
Cells(1, 2).Select
Case 1
Cells(1, 1).Select
Case 2
Cells(2, 1).Select
Case 3
Cells(3, 1).Select
Case 4
Cells(3, 2).Select
Case 5
Cells(3, 3).Select
Case 6
Cells(3, 4).Select
Case 7
Cells(2, 4).Select
Case 8
Cells(1, 4).Select
Case 9
Cells(1, 3).Select

End Select

Application.Wait (Now + TimeValue("0:00:01") * wt)
wt = wt * 0.8
Loop

c = 11 - i
Cells(c, 6) = "第" & (10 - i) & "次抽签结果"
Cells(c, 7) = i
MsgBox "第" & (10 - i) & "次抽签结果为: " & i
Next

End Sub

Sub 新建抽签表()
'
' Macro2 Macro
'

'
Sheets.Add After:=Sheets(Sheets.Count