How to find and replace text within comments in Excel?
As we know, there is a Find and Replace function in excel, and with this function, we can find and replace the content in cells quickly. But can we find and replace contents in comments in Excel?
In Excel, it seems there is no other way to solve this problem except using VBA code, you can use the following VBA code to find and replace text in all comments. For example, I will replace 2011 with 2012 in all comments in Excel.
1. Click Developer >Visual Basic, a new Microsoft Visual Basic for applications window will be displayed, click Insert > Module and then input the following VBA code in the Module:
VBA: find and replace text in all comments in Excel.
Dim cmt As Comment
Dim wks As Worksheet
Dim sFind As String
Dim sReplace As String
Dim sCmt As String
sFind = "2011"
sReplace = "2012"
For Each wks In ActiveWorkbook.Worksheets
For Each cmt In wks.Comments
sCmt = cmt.Text
If InStr(sCmt, sFind) <> 0 Then
sCmt = Application.WorksheetFunction. _
Substitute(sCmt, sFind, sReplace)
Set wks = Nothing
Set cmt = Nothing
Note: In the above code, you can set the sFind and sReplace variables for what you are searching for and what you want to replace with.
2. Then click button to run the code, and all 2011 in all comments will be replaced with 2012 in the whole workbook.
We can quickly find and replace text in all comments with Kutools for Excel’s Cell Comment Tools.
If you have installed Kutools for Excel, you could easily find and replace the text in all comments in Excel.
1. Click Kutools > More > Cell Comment Tools. See screenshot:
2. In the Cell Comment Tools dialog box:
- (1.) Click Find/Replace tab;
- (2.) Select the scope that you want to apply this utility, you can select Active sheet or All sheets;
- (3.) Enter the text (2011) that you want to replace into the Find text in comments box, and input the specific text (2012) that you want to use in the Replace with box.
3. And then click Replace button. All of 2011 will be replaced with 2012 within the comments in active worksheet. See screenshots:
Note: If you checked Show summary, there will be a prompt box to remind you how many cell comments have been changed.
For more detailed information about Cell Comment Tools, please visit Cell Comment Tools feature description.
- Change all comment formats in cells
- Change all comments' author name
- List all comments to a new worksheet or workbook
- Show or hide all comments and comment indicators in Excel
- Convert cell contents to comments in Excel
- Convert comments to cell contents in Excel
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!