Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check a comment is exist?

Status
Not open for further replies.

sanjna000

Programmer
Aug 1, 2003
132
0
0
GB
Hi,

I need to check whether a comment is available in my active cell. If it is already exist in the active cell then I need to add a string to the exisiting comment. Otherwise need to add a new comment.

This is what i want:

If ActiveCell does not have a Comment
ActiveCell.AddComment
ActiveCell.Comment.Visible = False
ActiveCell.Comment.Text Text:="Extra minutes added " & Chr(10) & WB_VLength & ""
Else
ActiveCell.Comment.Text Text:=ActiveCell.Comment.Text & Chr(10) & "Extra minutes added " & Chr(10) & WB_VLength & ""
End If


Does anyone know how to do it?

Thank you very much for u r help!
Sanjna...

 
Making it hard for yourself. Just clear any comment and put the new one. No error is produced if the comment does not exist.
Code:
' partial code
ActiveCell.ClearComments
ActiveCell.AddComment ... etc.



Regards
BrianB
Use CupOfCoffee to speed up all windows applications.
It is easy until you know how.
================================
 
Hi sanjna,

If a cell does not have a comment then the Comment property returns Nothing, so you can do something like ..

Code:
[blue]If ActiveCell.Comment Is Nothing Then
    ActiveCell.AddComment Text:="Extra minutes added "     &    Chr(10) & WB_VLength & ""
Else
    ActiveCell.Comment.Text  Text:=ActiveCell.Comment.Text & Chr(10) & "Extra minutes added " & Chr(10) & WB_VLength & ""
End If[/blue]

Brian,

No good clearing comments if you want to append to the existing one, so he does need a way to check.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.
 
I stand corrected. (Blush)


Regards
BrianB
Use CupOfCoffee to speed up all windows applications.
It is easy until you know how.
================================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top