大家好我是Excel从零到一,今天闲来无聊做了一套大乐透摇号程序的vba代码分享给大家
来看下效果
Excel大乐透摇号vba代码分享,说不定就中百万了呢
Sub 摇号()
Dim i, a, test, s(1 To 35) As Integer
For i = 1 To 5
line1: test = Application.WorksheetFunction.RandBetween(1, 35)
For a = 1 To i
If s(a) = test Then
GoTo line1
End If
Next
s(i) = test
Cells(3, i) = s(i)
Next
Call y
End Sub
Sub y()
Dim s, h, testy, q(1 To 12) As Integer
For i = 6 To 7
line1: testy = Application.WorksheetFunction.RandBetween(1, 12)
For h = 1 To i
If q(h) = testy Then
GoTo line1
End If
Next
q(i) = testy
Cells(3, i) = q(i)
Next
End Sub
打开vb编辑器,将代码复制进去,然后找到宏点击摇号即可摇号
都来试试把,万一中奖了,别忘了分给小编点吃个中午饭~