电脑教程
位置:首页>> 电脑教程>> office教程>> excel用自定义函数获取单元格注释

excel用自定义函数获取单元格注释

  发布时间:2023-03-11 10:50:58 

标签:函数,单元格,注释,自定义,Excel函数

我们可以用一个自定义函数来提取单元格注释。方法如下:

1.按Alt+F11,打开VBA编辑器。

2.单击菜单“插入→模块”,在右边的代码窗口中输入代码:

Function GetCommentText(rCommentCell As Range)
Dim strGotIt As String
On Error Resume Next
strGotIt = WorksheetFunction.Clean(rCommentCell.Comment.Text)
GetCommentText = strGotIt
On Error GoTo 0
End Function

3.关闭VBA编辑器。在单元格中输入公式:

=GetCommentText(B4)

将在当前单元格中返回B4单元格中的注释。

0
投稿

猜你喜欢

手机版 电脑教程 asp之家 www.aspxhome.com