'' ***************************************************************************
'' Purpose : Delete comments from all cells
'' Written : 13-Feb-2003 by Andy Wiggins, Byg Software Limited
''
Sub CommentReplace()
Dim ce
Dim sh As Worksheet
Dim lStr_Comm As String
Dim lStr_Find As String
Dim lStr_Repl As String
Dim lLng_Len As Long
Dim lLng_CellCount As Long
'' Find this
lStr_Find = "Andy Wiggins, Byg Software Ltd"
lLng_Len = Len(lStr_Find)
'' And replace it with this
lStr_Repl = "INTEC"
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'' Ensure we are in this workbook
ThisWorkbook.Activate
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'' Set trap
On Error Resume Next
'' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'' Loop through all worksheets in current book
For Each sh In Worksheets
sh.Activate
sh.Cells.SpecialCells(xlCellTypeComments).Select
If Err > 0 Then
lLng_CellCount = 0
Err = 0
Else
lLng_CellCount = Selection.Count
For Each ce In Selection
lStr_Comm = ce.Comment.Text
If Len(lStr_Comm) > 0 Then
ce.Comment.Text Text:=Replace(lStr_Comm, lStr_Find, lStr_Repl)
End If
Next
End If
Next
End Sub
|