Hi,
At work we have sheets where several users enter comments and these all by default show their names in bold. I am hoping someone is able to help me with a little bit of code.
Currently I have a sub which finds in all comments certain text (eg "My Name:") and replaces it with blank (""). This works fine except when i tested this it formatted the remaining font bold and leaves a blank line at the top if the comment (ie where the users name was). I have added to the code so that it then runs through all comments again and sets the text style to 'normal'.
All I need now is help on removing the blank line at the top of the comment.
Note I know nothing about VBA, I have pieced the below code from various places. If anyone has a easier way to remove names in comments (after comments have been made) then Im willing to try.
Sub ReplaceComments()
Dim cmt As Comment
Dim wks As Worksheet
Dim sFind As String
Dim sReplace As String
Dim sCmt As String
sFind = "2011"
sReplace = "2012"
For Each wks In ActiveWorkbook.Worksheets
For Each cmt In wks.Comments
sCmt = cmt.Text
If InStr(sCmt, sFind) <> 0 Then
sCmt = Application.WorksheetFunction. _
Substitute(sCmt, sFind, sReplace)
cmt.Text Text:=sCmt
End If
Next
Next
Set wks = Nothing
Set cmt = Nothing
Dim MyComments as comment
Dim LArea As Long
For Each MyComments In ActiveSheet.Comments
With MyComments
.Shape.TextFrame.Characters.Font.FontStyle = normal
End With
Next
End Sub
Thanks in advance!
Harribone
Bookmarks