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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making Comments in Excel

Status
Not open for further replies.

link99sbc

Technical User
Apr 8, 2009
141
US
A few tips on Comments.
[]
Sub FormatAllComments()
'Formats all comments on the sheet
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

Sub CommentFontChange()
'Formats the selected cell comment
With ActiveCell.comment.Shape.TextFrame.Characters.Font
.Name = "System" 'font
.Size = 10
.Bold = True
.ColorIndex = 1
End With
End Sub

Sub comment()
'Adds text comment to the selected cell
'Sets the font,size,color and autozize the comment box

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
Sub CommentAddOrEdit()
'adds comment to selected cell and text from Clipboard

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

 



Please post VBA code related items in forum707.

BYW, code without comments or any explanation is not very useful.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top