Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim h&
Application.EnableEvents = False
On Error Resume Next
If Target.Address = "$G$12:$V$12" Then
Application.ScreenUpdating = False
h = [Liste].Count
[Destinataire].EntireRow.Resize(h).Insert
[Destinataire].EntireRow.Offset(-h).Resize(h).Name = "Plage"
[Plage].Columns("G") = [Liste].Value
[Plage].EntireRow.Hidden = True 'masque les lignes insérées
Application.EnableAutoComplete = True 'option "Saisie semi-automatique..."
Else
[Plage].Delete 'supprime les lignes insérées
Application.EnableAutoComplete = False 'décoche l'option (facultatif)
End If
Target.Select
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Variant
If Target.Address = "$G$" & [Destinataire].Row Then
i = Application.Match(Target, [Liste], 0)
If IsError(i) Then
If MsgBox("Voulez-vous ajouter '" & Target & "' dans la liste ?", 4) = 6 Then
[Liste].Cells([Liste].Count + 1) = Target 'ajout en fin de liste
[Liste].Sort [Liste], Header:=xlNo 'tri
End If
End If
End If
End Sub