How to set cell to a comment from another cell?

  • Thread starter Pete at Sappi Fine Paper
  • Start date
P

Pete at Sappi Fine Paper

How do I make one cell equal to the comment in another cell? One would think
that =comment(A1) would do it, but of course it doesn't. Can anyone help?
 
G

Gary L Brown

You need a UDF (User Defined Function). Copy the UDF below...
'/=======================================/
Public Function Comment(rng As Range)
'rng must point to a single cell
'Get Text in a comment of one (1) cell
Application.Volatile

On Error GoTo err_Function

Comment = rng.Comment.Text

exit_Function:
On Error Resume Next
Exit Function

err_Function:
GoTo exit_Function

End Function
'/=======================================/
HTH,
 
P

Pete at Sappi Fine Paper

Thanks! I actually wrote a program to populate all the cells in my sheet
with the comments in the cells on another sheet, and now that I've written it
I might as well stick with it. However, now that you've taught me how to use
UDFs, I'll no doubt do so frequently in future! Thanks very much!
 
Top