Written by Allen Wyatt (last updated May 8, 2025)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, 2021, 2024, and Excel in Microsoft 365
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:
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.
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 2019 For Dummies today!
One of the pieces of information that Excel can maintain relative to a workbook is a set of comments of your choice. ...
Discover MoreWant to make your worksheet comments appear a certain way? It's easy to do using techniques you are already familiar with.
Discover MoreWhen formatting comments, you can use a graphic as a background for the comment box. If you later want to move this ...
Discover MoreFREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-04-09 10:55:29
Is there a way to do this for a certain selection instead of the entire sheet?
2018-01-27 10:48:35
Peter Atherton
Bill
Try this, a mashup of Allen's macro.
Option Explicit
Sub ListComments()
Dim cmt As Comment
Dim wks As Worksheet, cmtsList As Worksheet
Dim sCmt As String, i As Integer
Dim c As range, NextRow As Long
With Application
.ScreenUpdating = False
.DisplayAlerts = False
End With
For Each wks In ActiveWorkbook.Sheets
If wks.Name = "List Comments" Then
wks.Delete
Exit For
End If
Next wks
Set cmtsList = Worksheets.Add
With cmtsList
.Name = "List Comments"
[A1] = "Sheet Name"
[B1] = "Cell Ref"
[C1] = "Comment Text"
[A1:C1].Font.Bold = True
End With
NextRow = 2
For Each wks In ActiveWorkbook.Worksheets
For Each cmt In wks.Comments
sCmt = cmt.Text
Cells(NextRow, 1) = wks.Name
Cells(NextRow, 2) = cmt.Parent.Address
Cells(NextRow, 3) = sCmt
NextRow = NextRow + 1
Next
Next
cmtsList.range("A1:C1").EntireColumn.AutoFit
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
Set wks = Nothing
Set cmt = Nothing
End Sub
2018-01-26 15:02:41
Bill
is there a way to find all comments in a workbook and list them on a new worksheet by worksheet and cell reference?
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 © 2025 Sharon Parq Associates, Inc.
Comments