Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
On Error Resume Next 'si le nom n'existe pas
If (Not Intersect(Target, [B9]) Is Nothing Or [blocage]) And Not Intersect(Target, [B2:B5,D2]) Is Nothing Then
Application.Undo
ElseIf Not Intersect(Target, [B9]) Is Nothing Then
ThisWorkbook.Names.Add "blocage", True, Visible:=False 'nom masqué
ElseIf Not Intersect(Target, [D2]) Is Nothing Then
[B9] = [D2]
End If
Application.EnableEvents = True
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, [G2]) Is Nothing Then
ThisWorkbook.Names.Add "blocage", False, Visible:=False 'nom masqué
Application.EnableEvents = False
[B9] = [D2]
Application.EnableEvents = True
End If
End Sub