Try this:
Function AddComment(cell As Range, sText As String, _
Optional ByVal bAppend As Boolean, _
Optional bAutoSize As Boolean, _
Optional vMargin As Variant) As Boolean
' Adds or appends text to a comment
Dim i As Long
Dim iBeg As Long
If cell.Comment Is Nothing Then
bAppend = False
cell.AddComment
ElseIf Not bAppend Then
cell.Comment.Delete
cell.AddComment
End If
With cell.Comment.Shape.TextFrame
If bAppend Then iBeg = .Characters.Count
For i = 1 To Len(sText) Step 255
.Characters(iBeg + i).Text = Mid(sText, i, 255)
Next i
.AutoSize = bAutoSize
If IsArray(vMargin) Then
.AutoMargins = False
If UBound(vMargin) = 3 Then
.MarginLeft = vMargin(0) * 72
.MarginRight = vMargin(1) * 72
.MarginTop = vMargin(2) * 72
.MarginBottom = vMargin(3) * 72
End If
End If
End With
End Function
Bookmarks