jbrousseau
New Member
- Joined
- Apr 12, 2007
- Messages
- 30
Hello,
I am trying to insert a comment on data-validated cells in a column through VBA. There are multiple possible values in the range and each has their own conditional comment.
Eg,, if cell value = X, insert comment X. If cell value = Y, insert comment Y.
I've been searching the boards and hacking together bits and pieces of other users who have requested similar assistance, but it's not quite there.
Any help would be much appreciated!
Many thanks,
jb
I am trying to insert a comment on data-validated cells in a column through VBA. There are multiple possible values in the range and each has their own conditional comment.
Eg,, if cell value = X, insert comment X. If cell value = Y, insert comment Y.
I've been searching the boards and hacking together bits and pieces of other users who have requested similar assistance, but it's not quite there.
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address <> Range("F3:F300") Then Exit Sub
If Target = "Value X" Then
Target.ClearComments
Target.AddComment.Text Text:="This cell contains Value X"
If Target = "Value Y" Then
Target.ClearComments
Target.AddComment.Text Text:="This cell contains Value Y"
End If
End Sub
Any help would be much appreciated!
Many thanks,
jb