乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > 在Excel单元格里面添加批注的时候里面为什么会默认有我的名...

在Excel单元格里面添加批注的时候里面为什么会默认有我的名...

作者:乔山办公网日期:

返回目录:excel表格制作


批注中直接设置不具备该功能,可以使用VBA实现该功能。

VBA中Cell.AddComment (text)可实现增加批注的功能,text内可使用公式。

如下代码在所选择区域的单元格中增加批注,批注内容为单元格地址。

Sub AddCom()
On Error Resume Next
Dim myRange As Range
Dim myCell As Range
Set myRange = Application.InputBox("选择区域", Type:=8)
For Each myCell In myRange
myCell.AddComment (myCell.Address)
Next
End Sub


说明你电脑的用户账户,就是你开机输密码的地方,用户名是:张三,

这是EXCEl批注默认的,如果你开机用户是管理员模式administrator登陆的,那么这里就显示administrator

在审阅里面能看到。



在工作表标签上击右键,查看代码,在VBE窗口中点“插入”,模块,

在模块代码窗口中粘贴以下代码,然后按ALT+F8运行之,即可

Sub 添加批注()
For i = 1 To 2 '注:列遍历
For j = 4 To Cells(65536, i).End(3).Row '注:行遍历
If Cells(j, i) <> "" Then '检测非空
Dim a
a = ""
For K = 2 To [e65536].End(3).Row '遍历E列区域
If Cells(K, 5) = Cells(j, i) Then '比对数据
a = a & CStr(Cells(K, 6)) '获取对应F列的值存入变量a。
On Error Resume Next '容7a64e59b9ee7ad94337
    Cells(j, i).ClearComments '若有批注,先行删除
    Cells(j, i).AddComment '添加批注
    Cells(j, i).Comment.Visible = False '批注隐藏
    Cells(j, i).Comment.Text Text:=a '批注内容
    End If
Next
End If
Next
Next
End Sub

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网