Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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   Report Post  
Posted to microsoft.public.excel.programming
rog rog is offline
external usenet poster
 
Posts: 39
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Cell Comment

JE McGimpsey wrote in news:jemcgimpsey-
:

It's customary to provide a reference to the site:

http://www.contextures.com/xlcomments03.html


Hand duly slapped.

Wasn't sure about "advertising", but it's a very good site none the less.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can insert digital ink into Excel cell or a cell comment? Nickbray Excel Discussion (Misc queries) 1 June 2nd 10 03:53 AM
copy comment content to cell content as data not as comment Lilach Excel Discussion (Misc queries) 2 June 21st 07 12:28 PM
Create Cell Comment based on text in a cell on another worksheet Dave Fellman Excel Discussion (Misc queries) 2 March 15th 07 09:49 AM
I want to change comment printing cell 3 to whats in cell 3 Lonny and Rinda Excel Worksheet Functions 3 June 19th 06 08:36 PM
a comment plugin & copy paste directly from excel to comment ? fr. RFM Excel Worksheet Functions 0 December 1st 04 11:29 PM


All times are GMT +1. The time now is 12:08 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"