Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("O2")) Is Nothing Then
If Range("M2") = "" Or Target = "" Then Exit Sub
With Sheets("Actions HSE").ListObjects(1)
Set trouve = .ListColumns(3).Range.Find(Format(Range("M2"), "00"), LookIn:=xlValues)
If Not trouve Is Nothing Then
lig = trouve.Row - .Range.Row
nbCarGras = Len(Format(Now, "dd/mm/yy") & ": " & Target)
'on place le résultat à sa place
.DataBodyRange(trouve.Row - .Range.Row, 12) = Format(Now, "dd/mm/yy") & ": " & Target & Chr(10) & .DataBodyRange(trouve.Row - .Range.Row, 12)
'on remet tout en noir, sans gras
.DataBodyRange(trouve.Row - .Range.Row, 12).Font.Color = xlblack
.DataBodyRange(trouve.Row - .Range.Row, 12).Font.Bold = False
'on colore en rouge gras, le dernier commentaire
With .DataBodyRange(trouve.Row - .Range.Row, 12).Characters(Start:=1, Length:=nbCarGras).Font '11 corresponds au caractère 1
.Color = -16776961
.Bold = True
End With
End If
End With
End If
End Sub