Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rc&, j%, DListe$, n%, SPListe$(), i&
Cells.Validation.Delete 'RAZ
With [Tableau2]
If Target.Row = 1 Or Target.Column > .Columns.Count Then Exit Sub
rc = .Rows.Count
For j = 1 To .Columns.Count Step 2
DListe = DListe & "," & .Cells(1, j)
n = n + 1
ReDim Preserve SPListe(1 To n)
For i = 1 To rc
If .Cells(i, j + 1) <> "" Then SPListe(n) = SPListe(n) & "," & .Cells(i, j + 1)
Next i
SPListe(n) = Mid(SPListe(n), 2)
Next j
DListe = Mid(DListe, 2)
End With
'---listes de validation---
With ActiveCell.Validation
If ActiveCell.Column Mod 2 Then
.Add xlValidateList, Formula1:=DListe 'liste des départements
ElseIf ActiveCell(1, 0) <> "" Then
n = Application.Match(ActiveCell(1, 0).Text, Split(DListe, ","), 0)
.Add xlValidateList, Formula1:=SPListe(n) 'liste des sous-préfectures
End If
End With
End Sub