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
| Dim LigTir As Integer
Sub tirer()
Dim i As Integer, j As Integer, ColTir As Integer
Dim k As Byte, m As Byte
For m = 1 To 10
initialiser
For k = 1 To 14
If LigTir < 3 Then LigTir = 3
ColTir = Cells(LigTir + 1, Columns.Count).End(xlToLeft).Column
If ColTir < 39 Then ColTir = 39
If [M2].Value = 90 Then Exit Sub
Do
Randomize
i = Int(10 * Rnd): j = Int(11 * Rnd)
Loop While IsEmpty([B4].Offset(i, j))
[M2].Value = 1 + [M2].Value
With [O4].Offset(i, j)
.Value = [B4].Offset(i, j).Value
.Font.ColorIndex = 2
.Interior.ColorIndex = 1
End With
Cells(LigTir + 1, ColTir + 2 - k) = [B4].Offset(i, j).Value
[B4].Offset(i, j) = Empty
Next k
Next m
End Sub
Sub initialiser()
Dim i As Integer, j As Integer
Range("B4:K12,M2,O4:X12").ClearContents
For i = 0 To 8
For j = 0 To 9
[B4].Offset(i, j) = 10 * i + j + 1
Next j
Next i
LigTir = Cells(Rows.Count, 40).End(xlUp).Row
End Sub |
Partager