1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| Sub Cadeaux()
Randomize Timer
recommencetout:
nbr = 0
For i = 2 To 7
nbr = nbr + 1
Cells(i, 1) = nbr
Cells(i, 3) = nbr
Next
For i = 2 To 7
ok = 0
encoreunefois:
moi = Cells(i, 1)
toi = moi
While moi = toi
toi = Int(6 * Rnd) + 1
Wend
If Cells(toi + 1, 3) = moi Or Cells(moi + 1, 3) = toi Then
ok = ok + 1
If ok < 1000 Then
GoTo encoreunefois
Else
MsgBox "Il y a un probleme"
GoTo recommencetout
End If
End If
tmp = Cells(moi + 1, 3)
Cells(moi + 1, 3) = Cells(toi + 1, 3)
Cells(toi + 1, 3) = tmp
Next
End Sub |
Partager