Thread: comments
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika Dick Kusleika is offline
external usenet poster
 
Posts: 179
Default comments

Rod

You can use error checking to see if a comment exists. Unprotecting and
reprotecting is as good as any way to put the comments in. Here's an
example for checking if a comment exists, no protection stuff included.

Sub test()

Dim rng As Range
Dim OldComm As String

Set rng = Range("a1")

On Error Resume Next
OldComm = rng.Comment.Text

If Err = 0 Then
rng.Comment.Text OldComm & vbLf & "More comments here"
Else
rng.AddComment "First comment"
End If

On Error GoTo 0

End Sub

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Rod Taylor" wrote in message
.. .
I have a sub that will place a comment in the cell if the info is more

then
a certain number of charters.
However I have two problems with this.
first if I protect the sheet with userinterface only then it won't put in
the comment
I got around this by unprotect the sheet but wondering if there might be
another way.

My new problem is if the sub to place a comment is called and the cell
already has a comment there then the program hangs

If I new that there was already a comment there then I found out how to

turn
this into a variable and then place both in the cell as a comment.
so How do I find out if a cell currently has a comment or is there a

better
way to do this

Thanks in advance