Dim sOldComment As String, sNewComment As String, sFind As String, sReplace As String
Dim Cmt As Comment
Dim Bunka As Range
Set Bunka = List1.Range("A1")
sFind = 2011
sReplace = 2012
On Error Resume Next
Set Cmt = Bunka.Comment
On Error GoTo 0
If Cmt Is Nothing Then
MsgBox "Žádný komentář v buňce :" & vbNewLine & Bunka.Address(0, 0, xlA1, True)
Exit Sub
End If
sOldComment = Cmt.Text
sNewComment = Replace(sOldComment, sFind, sReplace)
Cmt.Text Text:=sNewComment
If sOldComment = sNewComment Then
MsgBox "Nepřišlo ke změně komentáře v buňce :" & vbNewLine & Bunka.Address(0, 0, xlA1, True)
Else
MsgBox "Byl nahrazen text :" & vbNewLine & sFind & vbNewLine & _
"novým textem :" & vbNewLine & sReplace & vbNewLine & _
"v buňce :" & vbNewLine & Bunka.Address(0, 0, xlA1, True)
End If
Set Cmt = Nothing
End Sub