I found this VBA on how to make it where comments are based on certain criteria, but i need it to do just a bit more and i am stumped. What i need it to do is to pick out a cell value for a range in column A and put the comment in the cell of the same row in column G. I need it to do this for 1000 rows.
Below is the code i have found that needs a modification.
Below is the code i have found that needs a modification.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim cell As Range
Dim c As Comment
On Error GoTo haveError
'see if any changes are in the monitored range...
Set rng = Application.Intersect(Target, Me.Range("C2"))
If Not rng Is Nothing Then
'Next line prevents code updates from re-triggering this...
' (Not really needed if you're only adding comments)
Application.EnableEvents = False
For Each cell In rng.Cells
If cell.Value = "Croatia" Then
Set rng = ActiveSheet.Cells(4, 3)
If Not (rng.Comment Is Nothing) Then rng.Comment.Delete
cell.Offset(2, 0).AddComment "Happy is as happy does"
'cell.Offset(0, 2).AddComment "fi"
'cell.Offset(0, 3).AddComment "fo"
End If
If cell.Value = "France" Then
Set rng = ActiveSheet.Cells(4, 3)
If Not (rng.Comment Is Nothing) Then rng.Comment.Delete
cell.Offset(2, 0).AddComment "Maybe yes"
'cell.Offset(0, 2).AddComment "fi"
'cell.Offset(0, 3).AddComment "fo"
End If
If cell.Value = "Spain" Then
Set rng = ActiveSheet.Cells(4, 3)
If Not (rng.Comment Is Nothing) Then rng.Comment.Delete
cell.Offset(2, 0).AddComment "Probably no"
'cell.Offset(0, 2).AddComment "fi"
'cell.Offset(0, 3).AddComment "fo"
End If
For Each c In ActiveSheet.Comments
c.Visible = False
Next
Next
Application.EnableEvents = True
End If
Exit Sub
haveError:
MsgBox Err.Description
Application.EnableEvents = True
End Sub
Last edited: