怎样使用VBA返回单元格之批注?
1、首先在开发工具中打开VBA编辑器

2、在单元格区域当中输入一些内容作为例子

3、在VBA编辑器中插入模块

4、在模块当中输入如下代码,然后运行
Function Comment(rng As Range) '提取批注
Application.Volatile
On Error GoTo err
If rng.Count=1 Then '如果选择单个单元格
Comment=rng.Comment.Text '取出批注
Else '否则
Comment="只能选单个单元格" '返回提示
End If
Exit Function
err:
Comment="" '当前单元格无批注时显示空白
End Function

5、在单元格B2中输入公式“=Comment(A2)”,则返回结果为空;若在单元格B3中输入公式“=Comment(A1:A3)”,则结果返回“只能选单个单元格”

阅读量:151
阅读量:190
阅读量:186
阅读量:74
阅读量:183