Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default VB Code to Add Comments to Cells from Several Other Cells

Need to add comments with a macro or VB code. Want to collect the
contents of several other cells, add them together as a text string
and then put them into a particular cell as a comment.

For example, I want to add comments to cells a1:a5 in Sheet1. Sheet2
contains the data I want to include in the comments in cells a1:c5.
The comment for cell a1 in Sheet1 needs to include the contents of
cells a1:c1 from Sheet2. Comment for a2 in Sheet1 comes from cells
a2:c2.

Thanks for any suggestions or sample code.

Mark
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VB Code to Add Comments to Cells from Several Other Cells

Sub Addcomments()
Dim sh1 As Worksheet
Dim sh2 As Worksheet
Set sh1 = Worksheets("sheet1")
Set sh2 = Worksheets("sheet2")
Dim cell As Range
For Each cell In sh1.Range("A1:A5")
On Error Resume Next
cell.Comment.Delete
On Error GoTo 0
cell.AddComment Text:=sh2.Cells(cell.Row, 1) & _
" " & sh2.Cells(cell.Row, 2) & " " & _
sh2.Cells(cell.Row, 3)
Next
End Sub

--
Regards,
Tom Ogilvy

"Mark" wrote in message
om...
Need to add comments with a macro or VB code. Want to collect the
contents of several other cells, add them together as a text string
and then put them into a particular cell as a comment.

For example, I want to add comments to cells a1:a5 in Sheet1. Sheet2
contains the data I want to include in the comments in cells a1:c5.
The comment for cell a1 in Sheet1 needs to include the contents of
cells a1:c1 from Sheet2. Comment for a2 in Sheet1 comes from cells
a2:c2.

Thanks for any suggestions or sample code.

Mark



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
How do I color code comments in cells on Excel spreadsheet? LBH Excel Worksheet Functions 1 September 27th 09 05:04 PM
how to filter cells where are comments... antares Excel Discussion (Misc queries) 1 May 16th 08 11:56 PM
Hide cells with comments in them. ICCDan Excel Discussion (Misc queries) 1 October 6th 07 01:46 AM
how can we copy cells comments text and paste to cells שי פלד Excel Discussion (Misc queries) 3 December 12th 05 05:16 AM
Comments in cells Double Excel Worksheet Functions 3 November 14th 05 09:56 PM


All times are GMT +1. The time now is 01:12 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"