HumanlyRespectable
HumanlyRespectable

Reputation: 203

Excel adding a comment onto a cell

I am currently trying to write a macro that when the user selects a cell in the spreadsheet and they click the button, a comment is added onto that selected cell. how would i go about doing that? i tried range(A1).addcomment and such but it did not seem to work, i don't know why, an error message always pops up and highlights the entire line but the message was not helpful at all. please help

i have tried this code here but it did not seem to work and gives me an error message

sub adding()
range(A1).addcomment
end sub

Upvotes: 1

Views: 4028

Answers (2)

C_Rod
C_Rod

Reputation: 303

The answer is as follows. You must add the comment and then the comment text can be edited.

Range("H13").Select
Range("H13").AddComment
Range("H13").Comment.Visible = False
Range("H13").Comment.Text Text:="Name:" & Chr(10) & "Test Comment" & Chr(10) & ""

Upvotes: 0

sridesmet
sridesmet

Reputation: 895

Try:

Sub SetComment()
      With ActiveCell
         .AddComment
         .Comment.Text Text:="This is a comment"
      End With
   End Sub

Upvotes: 3

Related Questions