來看下效果 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編輯器,將代碼復(fù)制進(jìn)去,然后找到宏點(diǎn)擊搖號即可搖號 都來試試把,萬一中獎(jiǎng)了,別忘了分給小編點(diǎn)吃個(gè)中午飯~ |
|