Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, and 2016. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Copying Comments to Cells.
by Allen Wyatt
(last updated February 26, 2021)
Hector has a large worksheet containing approximately 600 rows and 70 columns. Spread throughout these 43,000 cells are about 200 cells with comments. Hector wants to extract the comments and place them into cells to the right of the main body of the data table. If a comment, for instance, is attached to cell C43, then he'd like the text from that comment to end up in cell CC43 and the original comment to be deleted.
You might think that you could use Paste Special to perform the task, but that doesn't work. If you copy the original cells and then use Edit | Paste Special | Comments, then only the comments are pasted to the target cells. They are still comments, and not text in cells, which goes against Hector's goal.
The only way to handle this type of extraction is to use a macro. The following, when run on a selection of cells, will extract the comments, move the comment text, and then delete the original comment.
Sub CommentsToCells() Dim rCell As Excel.Range Dim rData As Excel.Range Dim sComment As String ' Horizontal displacement Const iColOffset As Integer = 78 ' extract comments from selected range If TypeName(Selection) = "Range" Then Set rData = Intersect(Selection, ActiveSheet.UsedRange) For Each rCell In rData.Cells On Error Resume Next sComment = rCell.Comment.Text If Len(sComment) > 0 Then rCell.Offset(, iColOffset).Value = sComment rCell.Comment.Delete End If sComment = "" On Error GoTo 0 Next End If End Sub
The macro uses the iColOffset constant to specify how many cells to the right a comment's text should be moved. In this case, the offset (78) is equal to three "alphabets" (26 * 3), so the text of a comment originally in column C will end up in column CC.
ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11837) applies to Microsoft Excel 2007, 2010, 2013, and 2016. You can find a version of this tip for the older menu interface of Excel here: Copying Comments to Cells.
Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!
Adding a comment to a single cell is easy. What if you want to add the same comment to multiple cells, however? Here are ...Discover More
One way that you can view comments in a worksheet is to have them appear when you hover the mouse pointer over a cell. If ...Discover More
Comments can be very helpful in a worksheet. After they are added, you may want to change what they contain. Here's how ...Discover More
FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
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.