ModusPonen
03-21-2011, 12:27 PM
I'm using the following code to add comments to cells, or add to the existing comments in cells. For some reason, it will work fine the first time through, but not the second. Any ideas?
Sub CommentTest()
Dim HasComment As Boolean
Dim oldCmtStr As String
Dim noteStr As String
noteStr = "hey there"
On Error Resume Next
HasCommnet = ActiveCell.Comment.Parent.Address = ActiveCell.Address
On Error GoTo 0
If HasComment = True Then
oldCmtStr = ActiveCell.Comment.Text
ActiveCell.Comment.Text Text:=oldCmtStr & Chr(10) & noteStr
Else
ActiveCell.AddComment Text:=noteStr
End If
End Sub
Sub CommentTest()
Dim HasComment As Boolean
Dim oldCmtStr As String
Dim noteStr As String
noteStr = "hey there"
On Error Resume Next
HasCommnet = ActiveCell.Comment.Parent.Address = ActiveCell.Address
On Error GoTo 0
If HasComment = True Then
oldCmtStr = ActiveCell.Comment.Text
ActiveCell.Comment.Text Text:=oldCmtStr & Chr(10) & noteStr
Else
ActiveCell.AddComment Text:=noteStr
End If
End Sub