Private Sub Worksheet_Change(ByVal Target As Range)
' insère la boite saisie commentaire
If Not Intersect(Target, Range("A30:C45")) Is Nothing Then
If Target = "" Then Target.ClearComments
If Target <> "" Then
Target.ClearComments
Target.AddComment
boucle:
commentaire = InputBox("Entrez votre commentaire")
If commentaire = "" Then MsgBox " attention", vbExclamation + vbOKOnly
If commentaire = "" Then GoTo boucle
Target.Comment.Text Text:=commentaire
Target.Comment.Text Text:=CStr(Now) & Chr(10) & Chr(10) & Target.Comment.Text & Chr(10)
lg = Len(Target.Comment.Text)
With Target.Comment.Shape.TextFrame
.Characters(Start:=1, Length:=lg).Font.Name = "Verdana"
.Characters(Start:=1, Length:=lg).Font.Size = 10
.Characters(Start:=1, Length:=lg).Font.Bold = True
.Characters(Start:=1, Length:=lg).Font.ColorIndex = 1
.Characters(Start:=lg, Length:=99).Font.ColorIndex = 1
End With
With Target.Comment.Shape ' taille du commentaire
.Width = 120 '
.Height = 90
End With
End If
End If
' couleur de fond commentaires
k = Range("A30:C45")
For Each k In ActiveSheet.Comments
k.Shape.Fill.ForeColor.SchemeColor = 5
k.Shape.AutoShapeType = msoShapeRoundedRectangle
Next k
End Sub