Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365. 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: Finding and Replacing Text in Comments.

Finding and Replacing Text in Notes and Comments

Written by Allen Wyatt (last updated May 10, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365


2

Gerry has a workbook containing 22 worksheets. Each worksheet has about 20 comments. Some of the comments make reference to a company division. He would like to do a mass search and replace of the comments to find each reference (for example, "ABC Division") and replace it with something else (for example, "XYZ subsidiary").

There is no way to do this without using a macro. The regular Find and Replace capabilities in Excel don't allow you to find text within notes or comments, but you can use macro commands. The following is a simple macro to do the replacing:

Sub ReplaceNotesComments()
    Dim c1 As Comment
    Dim c2 As CommentThreaded  ' Remove if Excel 2016 or earlier
    Dim w As Worksheet
    Dim sFind As String
    Dim sReplace As String
    Dim sCmt As String

    sFind = "ABC Division"
    sReplace = "XYZ subidiary"

    For Each w In ActiveWorkbook.Worksheets
        ' Replace in any notes
        For Each c1 In w.Comments
            sCmt = c1.Text
            If InStr(sCmt, sFind) <> 0 Then
                sCmt = Application.WorksheetFunction. _
                  Substitute(sCmt, sFind, sReplace)
                c1.Text Text:=sCmt
            End If
        Next

        ' Replace in any threaded comments
        ' Running on Excel 2016 and earlier will generate
        ' an error, so remove this code if on earlier version
        For Each c2 In w.CommentsThreaded
            sCmt = c2.Text
            If InStr(sCmt, sFind) <> 0 Then
                sCmt = Application.WorksheetFunction. _
                  Substitute(sCmt, sFind, sReplace)
                c2.Text Text:=sCmt
            End If
        Next
    Next
End Sub

The key lines here are those that set the sFind and sReplace variables. You should set those to reflect what you are searching for and what you want it replaced with, respectively.

Note, as well, that the macro has separate loops that step through first notes and then through comments. (Notes were called comments in Excel 2016 and earlier. Starting in Excel 2019, the old-fashioned comments are now called notes and comments now refer to threaded comments.) If you will be running this macro on older versions of Excel, 2016 and earlier, then you'll want to modify the macro by deleting the code indicated. You cannot just test for versions because, well, there is no straightforward way to test for versions these days and the Dim statement for variable c2 will generate an error right off the bat.

The macro works by stepping, first, through each comment (note) in each worksheet and making the changes. It then steps through each comment (threaded) and makes changes there, as well.

Note:

If you would like to know how to use the macros described on this page (or on any other page on the ExcelTips sites), I've prepared a special page that includes helpful information. Click here to open that special page in a new browser tab.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (11149) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365. You can find a version of this tip for the older menu interface of Excel here: Finding and Replacing Text in Comments.

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

Transposing Two Words

A common editing task is to transpose two adjacent words, so that their order is changed. While the task is common, there ...

Discover More

Calculating the First Tuesday

Do you need to figure out the date for the first Tuesday of any given month? Excel is incredibly flexible when it comes ...

Discover More

Finding Missing Spaces before Numbers

If you want to insert a space between letters and digits in your document, you have a couple of tasks to perform. First, ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 365 applications with VBA programming. Written in clear terms and understandable language, the book includes systematic tutorials and contains both intermediate and advanced content for experienced VB developers. Designed to be comprehensive, the book addresses not just one Office application, but the entire Office suite. Check out Mastering VBA for Microsoft Office 365 today!

More ExcelTips (ribbon)

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

Changing the Comment Font

When you add a comment to a worksheet, Excel uses a default font and size for the text. If you want to make changes to ...

Discover More

Viewing Comments

There are three different ways that Excel allows you to display any comments that are in your worksheet. Here's how you ...

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 3 + 9?

2025-05-13 11:05:43

J. Woolley

The Tip's macro can be simplified by using VBA's Replace function instead of Application.WorksheetFunction.Substitute; i.e., this statement
                sCmt = Application.WorksheetFunction. _
                    Substitute(sCmt, sFind, sReplace)
can be changed to this statement
                sCmt = Replace(sCmt, sFind, sReplace)
There are two instances in the macro.


2025-05-12 12:17:58

J. Woolley

For more about finding text in notes and comments, see https://excelribbon.tips.net/T007852_Searching_Comments.html


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.