Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static AncValeurC As String
Static AncValeurD As String
Static AncValeurE As String
On Error GoTo Sortie
Application.ScreenUpdating = False
Application.EnableEvents = False
If Not Intersect(Target, Columns("C")) Is Nothing Then
AncValeurC = Target
ElseIf Not Intersect(Target, Columns("D")) Is Nothing Then
AncValeurD = Target
ElseIf Not Intersect(Target, Columns("E")) Is Nothing Then
AncValeurE = Target
End If
Sortie:
Application.EnableEvents = True
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Static AncValeurC As String
Static AncValeurD As String
Static AncValeurE As String
On Error GoTo Sortie
Application.ScreenUpdating = False
Application.EnableEvents = False
If Not Intersect(Target, Columns("C")) Is Nothing Then
If Target.Count > 1 Then GoTo Sortie
If Target = "" Then
AncValeurC = ""
GoTo Sortie
End If
If AncValeurC <> "" Then Target = Target + AncValeurC * 1
AncValeurC = Target
ElseIf Not Intersect(Target, Columns("D")) Is Nothing Then
If Target.Count > 1 Then GoTo Sortie
If Target = "" Then
AncValeurD = ""
GoTo Sortie
End If
If AncValeurD <> "" Then Target = Target + AncValeurD * 1
AncValeurD = Target
ElseIf Not Intersect(Target, Columns("E")) Is Nothing Then
If Target.Count > 1 Then GoTo Sortie
If Target = "" Then
AncValeurE = ""
GoTo Sortie
End If
If AncValeurE <> "" Then Target = Target + AncValeurE * 1
AncValeurE = Target
End If
Sortie:
Application.EnableEvents = True
End Sub