Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, [C:C]) Is Nothing Then Exit Sub
[D:D].Validation.Delete 'RAZ
[G:G].ClearContents 'RAZ
If Target.Count > 1 Or Not (Target(1) Like "####" Or Target(1) Like "#####") Then Exit Sub
Dim code&, tablo, lig&, i&
code = Target
tablo = Sheets("codepostal").[A1].CurrentRegion.Resize(, 2) 'matrice, plus rapide
lig = 1
Application.EnableEvents = False 'désactive les évènements
For i = 2 To UBound(tablo)
If tablo(i, 2) = code Then Cells(lig, "G") = tablo(i, 1): lig = lig + 1
Next
Application.EnableEvents = True 'réactive les évènements
If lig = 1 Then Exit Sub
With [G1].Resize(lig - 1)
Target(1, 2).Validation.Add xlValidateList, Formula1:="=" & .Address
.Sort .Cells(1), xlAscending, Header:=xlNo 'tri
End With
Target(1, 2).Select
CreateObject("wscript.shell").SendKeys "%{DOWN}" 'déroule la liste
End Sub