首页 > 其他分享 >excel内容改变,自动添加批注。

excel内容改变,自动添加批注。

时间:2022-12-27 09:35:37浏览次数:43  
标签:r1 批注 Sub r2 excel 添加 Exit Comment Target

Dim r1
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.CountLarge <> 1 Then Exit Sub
If Target.Formula = "" Then
r1 = "空"
Else
r1 = Target.Text
End If
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count <> 1 Then Exit Sub
Dim r2
If Target.Formula = "" Then
r2 = "空"
Else
r2 = Target.Formula
End If
If r1 = r2 Then Exit Sub
Dim r3
Dim r4
Set r3 = Target.Comment
If r3 Is Nothing Then Target.AddComment
r4 = Target.Comment.Text
Target.Comment.Text Text:=r4 & Chr(10) & Format(Now(), "yyyy-mm-dd hh:mm") & "原内容:" & r1 & "修改为:" & r2
Target.Comment.Shape.TextFrame.AutoSize = True
End Sub

 

标签:r1,批注,Sub,r2,excel,添加,Exit,Comment,Target
From: https://www.cnblogs.com/aliensky/p/17007341.html

相关文章