Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Tablo(1 To 46, 1 To 25), TLots(), L As Long, C As Long, TAléa() As Long, P As Long, N As Long
If Target.Column < 22 Then Exit Sub
If MsgBox("Un nouveaau tirage va être effectué", vbOKCancel + vbInformation, _
"Tombola") = vbCancel Then Exit Sub
TLots = Me.[D56].Resize(Me.[D1056].End(xlUp).Row - 55).Value
ReDim TAléa(1 To 700 - 400)
Randomize
For P = 1 To UBound(TAléa): TAléa(P) = P: Next P
For P = UBound(TAléa) To 2 Step -1
C = Int(Rnd * P) + 1: N = TAléa(C): TAléa(C) = TAléa(P): TAléa(P) = N
Next P
For P = 1 To UBound(TAléa)
N = TAléa(P)
L = (N - 1) Mod UBound(Tablo, 1) + 1
C = ((N - 1) \ UBound(Tablo, 1)) * 3 + 1
Tablo(L, C) = N + 400 ' Corrigé
If P <= UBound(TLots, 1) Then
Tablo(L, C + 1) = "Gagné": Tablo(L, C + 2) = TLots(P, 1)
L = (P - 1) Mod UBound(Tablo, 1) + 1
C = (P - 1) \ UBound(Tablo, 1) + 22
Tablo(L, C) = N + 400 ' Corrigé
Else: Tablo(L, C + 1) = "Perdu": End If: Next P
Me.[A2:Y47].Value = Tablo
End Sub