Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim s As Boolean, acr, acc%, t, d As Object, i&, dercol%, j%
s = ThisWorkbook.Saved
Cells.Validation.Delete 'RAZ
acr = ActiveCell.Row: acc = ActiveCell.Column
If acr > 1 And acc > 1 Then
With Feuille1 'CodeName de la feuille "Joueurs à traiter"
.[A:B].Sort .[A1], xlAscending, Header:=xlNo 'tri de la liste des joueurs
t = .[A1].CurrentRegion.Resize(, 2) 'au moins 2 éléments
Set d = CreateObject("Scripting.Dictionary")
d.CompareMode = vbTextCompare 'la casse est ignorée
For i = 1 To UBound(t): d(t(i, 1)) = "": Next i 'liste des joueurs sans doublon
dercol = Me.UsedRange.Column + Me.UsedRange.Columns.Count - 1
t = Range("A1", Cells(acr + 29, dercol))
For i = Application.Max(1, acr - 29) To acr + 29
For j = 2 To dercol
If d.exists(t(i, j)) And (i <> acr Or j <> acc) Then d.Remove t(i, j) 'supprime les joueurs indisponibles
Next j, i
If d.Count Then
.Columns("D") = "" 'RAZ
.[D1].Resize(d.Count) = Application.Transpose(d.keys)
.[D1].Resize(d.Count).Name = "Liste" 'plage nommée
ActiveCell.Validation.Add xlValidateList, Formula1:="=Liste" 'crée la liste de validation
Else
ActiveCell.Validation.Add xlValidateTextLength, Formula1:=0, Formula2:=0 'interdit l'entrée de toute donnée
End If
End With
End If
If s Then ThisWorkbook.Saved = True 'évite l'invite à la fermeture si aucune autre modification
End Sub