Hi,
Thank you so much for all the videos you put on youtube, it's been great help!
Quick question, is there a way to find and replace in comments?
Thanks
Hi,
Thank you so much for all the videos you put on youtube, it's been great help!
Quick question, is there a way to find and replace in comments?
Thanks
You're very welcome! :)
This is an interesting question and it's actually pretty easy, but it requires a macro.
Here is a small macro that I made that had 2 pop-up windows, one for the value to search for and 1 for the value to use as a replacement. Once it runs, it will show a window with a count of how many values were replaced.
Sub ReplaceComments()
Dim eComment As Comment
Dim eSheet As Worksheet
Dim valueFind As String
Dim valueReplace As String
Dim commentText As String
Dim numberReplaced As Long
numberReplaced = 0
valueFind = InputBox("Value to find:")
valueReplace = InputBox("New value to replace old value with:")
For Each eSheet In Sheets
For Each eComment In eSheet.Comments
commentText = eComment.Text
If InStr(commentText, valueFind) <> 0 Then
commentText = Application.WorksheetFunction. _
Substitute(commentText, valueFind, valueReplace)
eComment.Text Text:=commentText
numberReplaced = numberReplaced + 1
End If
Next
Next
If numberReplaced > 0 Then
MsgBox numberReplaced & " replacements made."
Else
MsgBox "Nothing found to replace."
End If
End Sub
I just made this but only tested it a little bit.
Let me know how it works :)