In an Excel 2007 worksheet I am inserting the same comment in consecutive cells, twenty or more, in a column. Then I could have a different comment to repeat in further multiple cells. I have used Copy and Paste and in doing so, due to the repetition involved, thought of recording a macro. But I would end up with a significant number of macros, many of the comments being different.
As with cell Fill Down is there an elegant way of repeating a comment in multiple cells? My Google search was not inspiring!
Malcolm
Inserting Comments in Multiple Cells
-
- 3StarLounger
- Posts: 227
- Joined: 08 Feb 2010, 22:27
- Location: Mid-Cheshire, UK
-
- gamma jay
- Posts: 25455
- Joined: 17 Mar 2010, 17:33
- Location: Cape Town
Re: Inserting Comments in Multiple Cells
Just a wild guess since i'm not in front of my pc...
Could you not use autofill, since you say the cells are consecutive. Autofill the cell with the comment, then create the new comments and autofill again, etc...
Could you not use autofill, since you say the cells are consecutive. Autofill the cell with the comment, then create the new comments and autofill again, etc...
Regards,
Rudi
If your absence does not affect them, your presence didn't matter.
Rudi
If your absence does not affect them, your presence didn't matter.
-
- Administrator
- Posts: 12604
- Joined: 16 Jan 2010, 15:49
- Location: London, Europe
Re: Inserting Comments in Multiple Cells
You could use a couple of simple Macros like
Code: Select all
Dim strCommentText As String
Sub CopyComment()
strCommentText = ActiveCell.Comment.Text
End Sub
Sub PasteComment()
Dim cl As Range
For Each cl In Selection
If Not cl.Comment Is Nothing Then cl.Comment.Delete
cl.AddComment strCommentText
Next cl
End Sub
StuartR
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Inserting Comments in Multiple Cells
Alternatively, here is a macro that will prompt you for a text string, then add it to every cell in the current selection:
Code: Select all
Sub AddComments()
Dim rngCell As Range
Dim strText As String
strText = InputBox("Enter comment")
If strText <> "" Then
For Each rngCell In Selection
If Not rngCell.Comment Is Nothing Then
rngCell.Comment.Delete
End If
rngCell.AddComment Text:=strText
Next rngCell
End If
End Sub
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 227
- Joined: 08 Feb 2010, 22:27
- Location: Mid-Cheshire, UK
Re: Inserting Comments in Multiple Cells
Gentlemen, Thank you each for your response. It's very pleasing to have your solution so promptly in answer to my enquiry.
I have tried Hans solution and it comprehensively fulfils my requirements to the letter.
Thank you Rudi, Stuart and Hans,
Malcolm
I have tried Hans solution and it comprehensively fulfils my requirements to the letter.
Thank you Rudi, Stuart and Hans,
Malcolm