1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Dim n As String, commentaire As String
Dim c As Range
Set isect = Application.Intersect(Target, Range("c8:c33"))
If isect Is Nothing Then
Exit Sub
Else
n = ActiveCell.Value
For Each c In Range("b101:b164")
If c.Value = n Then
commentaire = c.Offset(0, 1).Value
End If
Next c
ActiveCell.ClearComments
ActiveCell.AddComment
ActiveCell.Comment.Text Text:=commentaire
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Dim n As String, commentaire As String
Dim c As Range
Set isect = Application.Intersect(Target, Range("e8:e33"))
If isect Is Nothing Then
Exit Sub
Else
n = ActiveCell.Value
For Each c In Range("d101:d110")
If c.Value = n Then
commentaire = c.Offset(0, 1).Value
End If
Next c
ActiveCell.ClearComments
ActiveCell.AddComment
ActiveCell.Comment.Text Text:=commentaire
End If
End Sub |
Partager