Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Target.Column = 8 Then 'colonne H
'effacer le mot FIN d'une date précédente
Set ancien = Range("CHRONO_DATE").Offset(Target.Row - 4, 0).Find("FIN")
If Not ancien Is Nothing Then
ancien.ClearContents
End If
'on cherche la position du mot FIN à placer
Set ici = Range("CHRONO_DATE").Find(Target)
If Not ici Is Nothing Then
Cells(Target.Row, ici.Column) = "FIN"
Else
MsgBox ("cette date n'apparait pas dans le planning")
Target.ClearContents
End If
End If
If Target.Column = 7 Then 'colonne G
'effacer le mot PBL d'une date précédente
Set ancien = Range("CHRONO_DATE").Offset(Target.Row - 4, 0).Find("PBL")
If Not ancien Is Nothing Then
ancien.ClearContents
End If
'on cherche la position du mot FIN à placer
Set ici = Range("CHRONO_DATE").Find(Target)
If Not ici Is Nothing Then
Cells(Target.Row, ici.Column) = "PBL"
Else
MsgBox ("cette date n'apparait pas dans le planning")
Target.ClearContents
End If
End If
Application.EnableEvents = True
End Sub