Linking comments

Z

Zork

Is there any way to link comments from once cell to another. When you link
the contents of one cell to another, is there anyway to capture the comments
as well.
 
D

Dave Peterson

How about a userdefined function:

Option Explicit
Function EchoComment(FCell As Range) As Variant
Application.Volatile

With Application.Caller
If .Comment Is Nothing Then
'do nothing
Else
.Comment.Delete
End If

If FCell.Comment Is Nothing Then
'do nothing
Else
.AddComment Text:=FCell.Comment.Text
End If
End With

EchoComment = FCell.Value

End Function

You'd use it like this:

=echocomment(a1)

The value in A1 would appear in the cell and the comment would get copied, too.

The application.volatile is there to update the comments if you change them.
(Changing the comment won't make the function run, but it'll catch up with then
next recalculation.)

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top