LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #15   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Making a comment using a cell?

Sub Comment_Add_Cell()
Dim cmt As Comment
Dim r As Range
Dim rr As Range
Set r = ActiveSheet.Range("A1")
Set rr = Sheets("Sheet2").Range("B1")
On Error Resume Next
r.Comment.Delete
Set cmt = r.Comment
If cmt Is Nothing Then
Set cmt = r.AddComment
cmt.Text Text:=rr.Text
End If
End Sub

Code for a range of cells will have to wait until after the hockey game.

Go Philly!!


Gord

On Mon, 24 May 2010 13:18:02 -0700, Gary McCarthy
wrote:

Gord,

Is there a way to do this referencing a cell on another tab? For example
Sheet2!B1 ?

Thanks.

"Gord Dibben" wrote:

Sub Comment_Add_Cell()
Dim cmt As Comment
Dim r As Range
Set r = Range("A1")
On Error Resume Next
r.Comment.Delete
Set cmt = r.Comment
If cmt Is Nothing Then
Set cmt = r.AddComment
cmt.Text Text:=r.Offset(1, 1).Text
End If
End Sub

'For a range of cells in A with text in B

Sub Comment_Add_Range()
Dim cmt As Comment
Dim r As Range
For Each r In Range("A1:A10")
On Error Resume Next
r.Comment.Delete
Set cmt = r.Comment
If cmt Is Nothing Then
Set cmt = r.AddComment
cmt.Text Text:=r.Offset(0, 1).Text
End If
Next r
End Sub

Either of these you could call from a Workbook_Open event in Thisworkbook
module

Private Sub Workbook_Open()
Sheets("Sheet1").Activate
Comment_Add_Range
'Comment_Add_Cell
End Sub


Gord

On Tue, 29 Jul 2008 12:38:01 -0700, NervousFred
wrote:

Gord your awesome, got it working how I want it.

One last question. I noticed, while trying to figure out the indexes for
Cells, that I had to delete the old comments first before the macro would
re-write the new comments over them.

Is there a delete comments line of code I could put ahead of the rest of the
code to make sure that everytime the macro is run it will put the new
information without me having to delete the old stuff first.

Also will this macro run automaticlly when the spreadsheet is opened? Just
trying to make it all autonomus without any user inputs.






 
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
Making a Cell turn color based on results in another cell melaniem Excel Discussion (Misc queries) 6 January 11th 08 05:25 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
Making cell reference absolute makes cell format text Excel Worksheet Functions 2 September 22nd 06 04:47 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 09:20 AM.

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

About Us

"It's about Microsoft Excel"