简体   繁体   English

Excel在单元格上添加注释

[英]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. 我尝试了range(A1).addcomment等,但它似乎没有工作,我不知道为什么,总是弹出一个错误信息并突出显示整行,但消息根本没有帮助。 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

Try: 尝试:

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

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) & ""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM