1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| Sub Bouton1_QuandClic()
Dim num As Integer, ligne As Integer, colonne As Integer, drapeau As Boolean
Range("E2:IV100").ClearContents
Range("B:B").ClearContents
While Range("C2") = False
num = Int(Rnd * Range("D4")) + 1
If Range("B" & num) = False Then
drapeau = False
While drapeau = False
ligne = Int(Rnd * (Range("D4") / Range("D5"))) + 1
colonne = Int(Rnd * Range("D5")) + 1
If Cells(1 + ligne, 4 + colonne) = "" Then
drapeau = True
Cells(1 + ligne, 4 + colonne) = Cells(num, 1)
Cells(num, 2) = True
End If
Wend
End If
Wend
End Sub |
Partager