您的位置:首页 > 编程语言 > VB

OFFICE 修改记录保存在单元格批注中vba

2014-06-26 09:21 113 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: