如何从条件中将注释作为单元格返回.
例:
=if(a1=0;insert comment on cell)
Run Code Online (Sandbox Code Playgroud)
插入评论并显示评论
我找不到默认工作表函数的任何方法,所以你可能必须为此声明自己的函数 - 像这样:
Public Function GetComment(rng As Range) as String
GetComment = rng.NoteText
'also possible
'GetComment = rng.Comment.Text
End Function
Run Code Online (Sandbox Code Playgroud)
将此功能保存到模块中,因此可以将其作为工作表功能访问.
然后=if(a1=0;GetComment(A1))用来返回评论.
编辑:
因为我可能误解了一点 - 这是一个verison,它向调用者单元格添加注释,将其内容设置为给定注释并使注释可见.
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4111 次 |
| 最近记录: |