ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Previous data in a comment (https://www.excelbanter.com/excel-programming/367320-previous-data-comment.html)

Who I Am

Previous data in a comment
 
I use the codes below to track versions (put the previous data in a
comment). But it only works for direct entry (directly typing data into
a cell). Is it possible to do the same thing for formula-generated
entry?

Thanks in advance



Option Explicit

Public acVal

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim ThisChange

ThisChange = Now()
On Error Resume Next
Target.AddComment
Target.Comment.Text "Before you make this change on " &
ThisChange & ", the value was " & acVal
Target.Comment.Shape.TextFrame.Characters(67).Font .Color =
RGB(255, 0, 0)
Target.Comment.Shape.TextFrame.Characters(1).Font. Size = 10

End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If ActiveCell.Address < Target.Address Then Exit Sub
If Target.Value = "" Then
acVal = ""
Else
acVal = Target.Value
End If
End Sub



All times are GMT +1. The time now is 01:54 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com