ChristineJ
Well-known Member
- Joined
- May 18, 2009
- Messages
- 771
- Office Version
- 365
- Platform
- Windows
I am using the code below to create comment boxes with text that appears in certain columns on the worksheet. There is intentionally one blank line inserted between each comment in the comment box. It works perfectly. However, it also leaves two blank lines after the last comment. Is there a way to eliminate the final two blank lines so that the final comment is the last line in the comment box? Thanks!
Code:
Sub AddCommentBox(rowNumber)
Dim c As Range
Dim commentText As String
Dim heading As String
Dim i As Integer
Dim x As String
heading = "FEEDBACK" & vbCrLf & vbCrLf
For i = 80 + columnReturn To 90 + columnReturn
x = IIf((Cells(rowNumber + rowReturn, i)) = "", "", vbCrLf)
If IsNumeric(Cells(rowNumber + rowReturn, i)) Then
commentText = commentText & Format(Cells(rowNumber + rowReturn, i), "#,###")
Else
commentText = commentText & Cells(rowNumber + rowReturn, i)
End If
commentText = commentText & x & x
Next i
Set c = Cells(rowNumber + rowReturn, 16 + columnReturn)
c.AddComment
c.Comment.Text Text:=heading & commentText
c.Comment.Shape.TextFrame.AutoSize = True
End Sub