如何从条件条件中将注释作为单元格返回。
示例:
=if(a1=0;insert comment on cell)
插入评论并显示评论
最佳答案
我找不到任何使用默认工作表函数的方法,因此您可能必须为此声明自己的函数 - 像这样:
Public Function GetComment(rng As Range) as String
GetComment = rng.NoteText
'also possible
'GetComment = rng.Comment.Text
End Function
将此函数保存到模块中,以便可以将其作为工作表函数进行访问。
然后使用=if(a1=0;GetComment(A1))
返回评论。
编辑:
因为我可能有点误解 - 这是一个版本,它将注释添加到调用者单元格,将其内容设置为给定的注释并使注释可见。
Public Function AddCmt(strComment As String) As String
Dim rngCaller As Range
If TypeName(Application.Caller) Like "Range" Then
Set rngCaller = Application.Caller
With rngCaller
If .Comment Is Nothing Then
.AddComment (strComment)
Else
.Comment.Text strComment
End If
.Comment.Visible = True
End With
'set caller-cell content to given comment
AddCmt= strComment
End If
End Function
关于Excel:如何从条件中将注释作为单元格返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12567167/