Hi Everyone,
I have a VBA code here that when data is entered into a cell within the range,
It automatically adds a note with a timestamp the only issue I have here is that if data is pasted into the cells or changed it resets the note with a new timestamp,
Is their anything that can be done to change this? and allow for old notes with comments to be pasted into these cells with out it resetting and removing comments in the note?
Thanks in advance,
I have a VBA code here that when data is entered into a cell within the range,
It automatically adds a note with a timestamp the only issue I have here is that if data is pasted into the cells or changed it resets the note with a new timestamp,
Is their anything that can be done to change this? and allow for old notes with comments to be pasted into these cells with out it resetting and removing comments in the note?
Thanks in advance,
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim oComment As Comment, cell As Range, strPrev As String
If Not Intersect(Target, Columns("H:K")) Is Nothing Then
For Each cell In Intersect(Target, Columns("H:K"))
Set oComment = Nothing
On Error Resume Next
Set oComment = cell.Comment
On Error GoTo 0
If Not oComment Is Nothing Then
strPrev = Mid(oComment.Text, InStr(oComment.Text, "Current value: ") + 15, 999)
oComment.Text Text:=Format(Now, "mmm dd, yyyy h:mm AM/PM")
ElseIf Not IsEmpty(cell) Then
cell.AddComment
cell.Comment.Text Text:=Format(Now, "mmm dd, yyyy h:mm AM/PM")
cell.Comment.Shape.Width = 150
cell.Comment.Shape.Height = 35
End If
Next cell
End If
End Sub