Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
I want to add a comment from VBA to a cell, I have
recorded the addcomment part but it falls over fi there is alreadya comment in place, how do I checkto see if the cell already has a comment, then append the new comment to the old Comment ? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
Hi
use something like with activecell on error resume next ..comment.delete on error goto 0 'insert your comment end with -----Original Message----- I want to add a comment from VBA to a cell, I have recorded the addcomment part but it falls over fi there is alreadya comment in place, how do I checkto see if the cell already has a comment, then append the new comment to the old Comment ? . |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
Neil, this should do what you want :
just pass it the cell you are interested in, and append the returned string (if any) to your new comment Function ReturnsCommentAndDeletes(ByRef p_rngCell As Range) As String Dim objComment As Comment Set objComment = p_rngCell.Comment ReturnsCommentAndDeletes = vbNullString If Not objComment Is Nothing Then ReturnsCommentAndDeletes = objComment.Text objComment.Delete End If End Function Rgds Rog -----Original Message----- I want to add a comment from VBA to a cell, I have recorded the addcomment part but it falls over fi there is alreadya comment in place, how do I checkto see if the cell already has a comment, then append the new comment to the old Comment ? . |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
"Neil" wrote in news:4b8901c48057$49229610
: I want to add a comment from VBA to a cell, I have recorded the addcomment part but it falls over fi there is alreadya comment in place, how do I checkto see if the cell already has a comment, then append the new comment to the old Comment ? Neil, Got this from a website, may/maynot help you. Sub CommentAddOrEditTNR() 'adds TimesNewRoman comment or positions 'cursor at end of existing comment text Dim cmt As Comment Set cmt = ActiveCell.Comment If cmt Is Nothing Then ActiveCell.AddComment text:="" Set cmt = ActiveCell.Comment With cmt.Shape.TextFrame.Characters.Font .Name = "Times New Roman" .Size = 11 .Bold = False .ColorIndex = 0 End With End If SendKeys "%ie~" End Sub |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
Frank - this won't append the new comment to an old comment.
Instead try: Public Sub AddOrAppendComment() Const sMYCOMMENT As String = "My Comment" Dim sExisting As String With ActiveCell If .Comment Is Nothing Then .AddComment sMYCOMMENT Else sExisting = .Comment.Text .Comment.Delete .AddComment sExisting & " " & sMYCOMMENT End If End With End Sub In article , "Frank Kabel" wrote: Hi use something like with activecell on error resume next .comment.delete on error goto 0 'insert your comment end with -----Original Message----- I want to add a comment from VBA to a cell, I have recorded the addcomment part but it falls over fi there is alreadya comment in place, how do I checkto see if the cell already has a comment, then append the new comment to the old Comment ? . |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
Hi JE
thanks - misread the OP's posting :-) Frank -----Original Message----- Frank - this won't append the new comment to an old comment. |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
It's customary to provide a reference to the site:
http://www.contextures.com/xlcomments03.html In article 05, Ron wrote: Got this from a website, may/maynot help you. |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
Here's a slight variation with AutoSize.
Public Sub AddOrAppendComment(s As String) With ActiveCell If .Comment Is Nothing Then .AddComment s Else .Comment.Text (.Comment.Text & vbLf & s) End If .Comment.Shape.TextFrame.AutoSize = True End With End Sub Dana DeLouis "JE McGimpsey" wrote in message ... Frank - this won't append the new comment to an old comment. Instead try: Public Sub AddOrAppendComment() Const sMYCOMMENT As String = "My Comment" Dim sExisting As String With ActiveCell If .Comment Is Nothing Then .AddComment sMYCOMMENT Else sExisting = .Comment.Text .Comment.Delete .AddComment sExisting & " " & sMYCOMMENT End If End With End Sub In article , "Frank Kabel" wrote: Hi use something like with activecell on error resume next .comment.delete on error goto 0 'insert your comment end with -----Original Message----- I want to add a comment from VBA to a cell, I have recorded the addcomment part but it falls over fi there is alreadya comment in place, how do I checkto see if the cell already has a comment, then append the new comment to the old Comment ? . |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Comment
|
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can insert digital ink into Excel cell or a cell comment? | Excel Discussion (Misc queries) | |||
copy comment content to cell content as data not as comment | Excel Discussion (Misc queries) | |||
Create Cell Comment based on text in a cell on another worksheet | Excel Discussion (Misc queries) | |||
I want to change comment printing cell 3 to whats in cell 3 | Excel Worksheet Functions | |||
a comment plugin & copy paste directly from excel to comment ? fr. | Excel Worksheet Functions |