Dim ydtext As String ‘原单元格值
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count = 1 Then
Dim mycom As Comment
Dim ybzstr As String ‘原标注值
‘------------------判断是否添加了批注
Set mycom = Target.Comment
If mycom Is Nothing Then Target.AddComment
‘------------------编辑批注内容
ybzstr = Target.Comment.Text
Target.Comment.Text Text:=ybzstr & Chr(10) & Format(Now(),
"yyyy-mm-dd hh:mm") & " 原内容: " & ydtext & "修改为: " &
Target.Formula
Target.Comment.Shape.TextFrame.AutoSize = True
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count = 1 Then
If Target = "" Then
ydtext = "空"
Else
ydtext = Target.Text
End If
End If
End Sub
OFFICE 修改记录保存在单元格批注中vba,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/coolsundy/p/3809368.html