View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Making a comment using a cell?

You mean when you change the text in any cell in B2:B4 the Comment does not
change when you run the macro?

It won't, because it already has a Comment so the macro skips that cell or
cells.

Try this revision which will change the text in existing Comments and add a
Comment if there is none.


Sub Comment_Add()
Dim cmt As Comment
Dim r As Range
For Each r In Range("A2:A4")
Set cmt = r.Comment
If Not cmt Is Nothing Then
cmt.Text Text:=r.Offset(0, 1).Text
Else
Set cmt = r.AddComment
cmt.Text Text:=r.Offset(0, 1).Text
End If
Next r
End Sub


Gord

On Thu, 8 Jan 2009 04:56:01 -0800, PSS
wrote:

I used this macro in Excel 2003. It worked until I change the
comments...the old comments remain in the comment box even when
I run the macro, save, close and reopen. Any advice? I started with a
small scale since I am new at attempting macros.
Here is what I used:

Sub Comment_Add()
Dim cmt As comment
Dim r As Range
For Each r In Range("A2:A4")
Set cmt = r.comment
If cmt Is Nothing Then
Set cmt = r.AddComment
cmt.Text Text:=r.Offset(0, 1).Text
End If
Next r
End Sub