The Andrew N. Wiggins Consultancy

Contact me at webmaster@anw.biz

Experimental Site

 

This site designed by Byg Software Ltd

 

The ANW.BIZ Home Page
Up

Comments

 
This only works if the cell (E13) previously contains a comment.
 
Sub Macro3()
    Range("E13").Select
    Range("E13").Comment.Text Text:="Andy Wiggins, Byg Software Ltd:" & Chr(10) & "" & Chr(10) & "aaa"
    Range("E13").Select
End Sub
 
When consulting for a client who is consulting on a project for a further client, this replaces my comment details with their details
 
'' ***************************************************************************
'' 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
   

Published: 17 January 2004
Last edited: 19 May 2008 16:43