excel抽獎(jiǎng)小工具

界面

抽獎(jiǎng)界面

使用說明

點(diǎn)擊”開始“,啟動(dòng)抽獎(jiǎng),停止顯示本次中獎(jiǎng)人.
清除按鈕,排除中獎(jiǎng)人。

代碼

Dim flag
Sub 開始()
c = Rnd
Dim rng As Range
Set dic = CreateObject("scripting.dictionary")
n = 0
For i = 2 To 201
If Application.WorksheetFunction.CountIf(Range("J3:L12"), _
Worksheets("人員名單列表").Cells(i, 1)) = 0 Then
n = n + 1
dic(n) = Worksheets("人員名單列表").Cells(i, 1)
End If
Next
flag = True
Do
DoEvents
If flag Then
Cells(4, 2) = dic(Int(Rnd * dic.Count + 1))
End If
Loop While flag
End Sub
Sub 停止()
flag = False
For i = 3 To 10
For j = 4 To 10
If Cells(i, j) = "" Then
Cells(i, j) = Cells(3, 4): GoTo 100
End If
Next
Next
100:
End Sub
Sub 清除()
For i = 2 To 100
c = Rnd
Next
Range("J3:L12").ClearContents
End Sub
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容