Article ID: 123574
Article Last Modified on 8/15/2005
Sub ReplaceCellNotes()
' Ask for original string.
oldstr = InputBox("replace what?")
' Ask for new string.
newstr = InputBox("replace with?")
' If the two numbers are not exactly the same, go into loop.
If oldstr <> newstr Then
' For every cell in the selection.
For Each c In Selection
' Find the starting location of the string in the note.
location = InStr(1, c.NoteText, oldstr, 1)
' If the string has been found, begin the check.
If location > 0 Then
' Get the section of the note before the found string.
begpiece = Left(c.NoteText, location - 1)
' Separate out the actual search string.
foundpiece = Mid(c.NoteText, location, Len(oldstr))
' Get the section of the note after the found string.
endpiece = Right(c.NoteText, Len(c.NoteText) _
- (location + Len(oldstr) - 1))
' Rebuild the note with the first piece, the new
' string, and the last old piece.
c.NoteText Text:=begpiece & newstr & endpiece
End If
' Next cell.
Next c
End If
End Sub
Additional query words: 5.00 7.00 XL
Keywords: kbhowto kbprogramming kbcode KB123574