Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add Comments in Excel from Clipboard

Status
Not open for further replies.

link99sbc

Technical User
Apr 8, 2009
141
US
A few tips on Comments.
[]'Formats all comments on the sheet

Sub FormatAllComments()

For Each x In ActiveSheet.Comments
With x.Shape.TextFrame.Characters.Font
.Name = "System" 'font
.Size = 10
.Bold = True
End With
Next x
End Sub

[]'Formats the comment in the selected cell

Sub CommentFontChange()

With ActiveCell.comment.Shape.TextFrame.Characters.Font
.Name = "System" 'font
.Size = 10
.Bold = True
.ColorIndex = 1
End With
End Sub

[]'Adds text comment to the selected cell
'Sets the font,size,color and autozize the comment box

Sub comment()

Dim objComment As comment

On Error Resume Next
Set objComment = ActiveCell.AddComment
If Err.Number <> 0 Then Set objComment = ActiveCell.comment

With objComment
.Visible = False
.Text Text:="OK"
.Shape.TextFrame.AutoSize = True
End With
With ActiveCell.comment.Shape.TextFrame.Characters.Font
.Name = "System" 'font
.Size = 14
.Bold = True
.ColorIndex = 3
.Shape.TextFrame.AutoSize = True
End With

End Sub

[]'adds comment to selected cell and text from Clipboard

Sub CommentAddOrEdit()

Dim objComment As comment

On Error Resume Next
Set objComment = ActiveCell.AddComment
If Err.Number <> 0 Then Set objComment = ActiveCell.comment

With objComment
.Visible = False
.Text Text:=""
.Shape.TextFrame.AutoSize = True
End With
With ActiveCell.comment.Shape.TextFrame.Characters.Font
.Name = "Arial" 'font
.Size = 10
.Bold = True
.ColorIndex = 1
.Shape.TextFrame.AutoSize = True
End With

Dim cmt As comment
Set cmt = ActiveCell.comment
If cmt Is Nothing Then
Set cmt = ActiveCell.AddComment
cmt.Text Text:=""
End If

'add Clipboard text to selected shape
cmt.Visible = True
cmt.Shape.Select
ActiveSheet.Paste
cmt.Visible = False

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top