- ·上一篇:excel表格怎么查相同数据
- ·下一篇:excel表格怎么到一个格
excel表格自动标注怎么设置
2025-01-08 10:43:14
1.excel表格如何自动加注批注?
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Count = 1 Then
Target.AddComment
Target.Comment.Visible = True
Target.Comment.Text Text:=Target.Value & ":" & Chr(10) & ""
End If
End Sub
2.Excel 2010怎么自动添加批注?
在工作表标签上击右键,查看代码,在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 '容错
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