Automatically Placing Text in a Comment

Written by Allen Wyatt (last updated February 10, 2022)
This tip applies to Excel 2007, 2010, 2013, and 2016


Grant has a cell in a worksheet that when someone starts typing in the cell, he would like whatever they type to end up in a comment attached to the cell. The cell itself should remain blank, but the comment should contain whatever was typed.

The only way to accomplish this task is through the use of a macro. Using the event handler capabilities of Excel, you can create a macro that is triggered whenever a cell is changed. If the changed cell happens to be the cell that you want the comment associated with, then you can transfer the cell contents to the comment and remove them from the cell itself. The following short macro will do that:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rCell As Range
    Dim sTemp As String

    Set rCell = Range("B4")
    If Not Intersect(Target, rCell) Is Nothing Then
        sTemp = rCell.Value
        rCell.ClearComments
        If Len(sTemp) > 0 Then
            Application.EnableEvents = False
            On Error Resume Next
            rCell.AddComment
            rCell.Comment.Text Text:=sTemp
            On Error GoTo 0
            rCell.ClearContents
            Application.EnableEvents = True
        End If
    End If
End Sub

Note that since this is an event handler, it needs to be added to the code module for the worksheet you want affected. In this case, the move-to-comment code is triggered only when a change is made in cell B4; this address can be changed in the code, if desired.

It should also be noted that this macro is only triggered once the user finishes entering something into cell B4. It isn't triggered as the user starts to type. So, actual data entry still occurs in cell B4, not in the comment itself. Further, if someone types something into cell B4, then any existing comment is lost because the macro deletes it before moving the cell contents into the comment.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13511) applies to Microsoft Excel 2007, 2010, 2013, and 2016.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Sorting with Graphics

If you use graphics in a worksheet that are associated with certain cells (perhaps images of parts or icons for worksheet ...

Discover More

Calculating the Day of the Year

Need to know what day of the year a certain date is? You can figure it out easily using the formulas in this tip.

Discover More

Deleting Tab Stops

Need to delete some tabs tops in a paragraph? It's easy to do using the Tabs dialog box, as described in this tip.

Discover More

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

More ExcelTips (ribbon)

Changing Comment Color for a Single User

The default color used to format comments is determined by Windows, not Excel. You can adjust the formatting of ...

Discover More

Anchoring Comment Boxes in Desired Locations

Want your comment boxes to appear someplace other than the right side of a cell? You may be out of luck, and here's why.

Discover More

Comments Don't Appear when Cell is Pointed To

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
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is four minus 0?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

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.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.