Written by Allen Wyatt (last updated June 6, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365
Malcolm needs to copy a range of cells and paste them into a comment. (He doesn't need to paste the formulas in the range, just the results of the formulas.) When he tries to do this, every time he makes the comment editable, Excel undoes his selection and he cannot paste.
Historically this can be a bit of a tricky operation because of the way that Excel handles copying and pasting. One way that people have often handled it is to copy the cells from Excel and then paste them into another program, such as Notepad. You can then copy them back out of the other program and paste them into your comment. If you didn't want to use another program as an intermediary, then the only solution was to use a macro to grab what is in the range and stuff it into a comment.
A better solution, however, is to use the Office Clipboard, which is sort of like an expanded version of the Windows Clipboard. To use the Office Clipboard effectively, all you need to do is display it. Just display the Home tab of the ribbon and click the small icon at the bottom-right of the Clipboard group. The Office Clipboard is displayed at the left side of your worksheet.
Now, go ahead and select the cells you want to copy into the comment. When you press Ctrl+C to copy them, you see that they appear in the Office Clipboard pane. (See Figure 1.)
Figure 1. The Office Clipboard pane.
To paste the range into a comment, simply insert the comment where you want (or choose to edit an existing comment) and then click the range in the Office Clipboard pane. It is placed exactly where you want it—in the comment.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12446) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Microsoft 365.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Need to find that misplaced comment in your worksheet? It's easy to do using the Find and Replace capabilities of Excel.
Discover MoreAdding comments to your worksheet can be helpful in documenting what the worksheet contains. If you want to make sure ...
Discover MoreIf you frequently add comments to cells in a worksheet, Excel provides a variety of tools you can use to manage those ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2019-07-30 05:27:15
Thanks Willy. Nice!
2019-07-29 12:36:59
Willy Vanhaelen
@Harold
Excelent idea but the macro can be simplfied a bit:
Sub PasteToComment()
Dim strData As String
' copy some range values
Sheet1.Range("C1:C31").Copy
' get the clipboard data
Dim O As New DataObject
O.GetFromClipBoard
strData = O.GetText
With ActiveCell
If .Comment Is Nothing Then .AddComment
.Comment.Text Text:=strData
End With
End Sub
You can also remove the "copy marching ants" by adding
Application.CutCopyMode = False
2019-07-28 06:48:03
Tim
Harold
Sub PasteToComment()
Thank you! Thank you! Thank you!
Worked perfectly once I leaarned how to set a reference to Microsoft.Forms
2019-07-27 11:07:45
Tim
Here is a macro that do what you want.
Make sure to set a reference to Microsoft.Forms
Sub PasteToComment()
Dim rngData As Range
Dim strData As String
Dim sActiveCell
' copy some range values
Set rngData = Sheet1.Range("C1:C31")
rngData.Copy
' get the clipboard data
' magic code for is for early binding to MSForms.DataObject
With CreateObject("New:{1C3B4210-F441-11CE-B9EA-00AA006B1A69}")
.GetFromClipBoard
strData = .GetText
End With
sActiveCell = ActiveCell.Address
With ActiveCell
If Not .Comment Is Nothing Then
Range(sActiveCell).Comment.Text Text:=strData
Else
Range(sActiveCell).AddComment
Range(sActiveCell).Comment.Text Text:=strData
End If
End With
End Sub
2019-07-27 09:36:28
Peter Atherton
Tim, try this macro
Sub copy2Comment()
Dim cmt As Comment, rng As Range, _
rng2Copy As Range, c As Range
Dim txt As String, str As String, Addr As String
Set rng = Selection.Areas(1)
Set rng2Copy = Selection.Areas(2)
If Selection.Areas.Count <> 2 Then
MsgBox "Select two Areas!", vbCritical
Exit Sub
End If
Addr = rng.Address
'pgc01 - Mr Excel 5th Aug 2006
If Range(Addr).Comment Is Nothing Then
Range(Addr).AddComment
Else
txt = Range(Addr).Comment.Text
End If
For Each c In rng2Copy
str = str & c & Chr(10)
Next
Range(Addr).Comment.Shape.Select
Range(Addr).Comment.Text Text:=txt & str
Range(Addr).Comment.Shape.TextFrame.AutoSize = True
End Sub
You must select two ranges, the comment range and the range to copy in that order. The comment range can be part of the data set; and so will be selectred twice. Note, it does actally copy anythng ;- )
2019-07-26 06:11:31
Tim
So how would this be done with a macro. Paste a range (C1:C31) of textI in to the comments of the active cell.
2018-09-12 10:20:00
James Woolley
@rajendra: I don't think you can paste into an Excel comment "with format." If you pick Review > Edit Comment, then right-click within the comment, you will see only one Paste option (which is the same as Ctrl+V). I don't think you can even develop a macro to paste into an Excel comment "with format," but it's an interesting challenge.
2018-09-12 01:31:57
rajendra
I have table in MS outlook email body.
This has to be pasted in Excel in comment as it is with format
Request your help
2018-09-04 13:37:59
Ronmio
I hadn't really used the handy Office Clipboard. Pretty slick. And it was right there all the time.
2018-09-01 10:24:37
J. Woolley
You could use the CopyValues macro I posted 2018-08-05; see http://excelribbon.tips.net/T013558_Pasting_Numeric_Values_in_Other_Programs.html#comment-form-hd
Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments