T
tpeter
I have found the following code online and it adds a comment to a cell if
someone changes it. It works fine in the free download and if I paste the
code into a blank workbook. But when I put it into a specific worksheet I
have the code breaks on the format date function. Any help would be great.
Option Explicit
Public preValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("$C$15:$j$15")) Is Nothing Then Exit Sub
Target.ClearComments
Target.AddComment.Text Text:="Previous Value was " & preValue & Chr(10)
& "Revised " & Format(Date, "mm-dd-yyyy") & Chr(10) & "By " &
Environ("UserName")
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("$C$15:$j$15")) Is Nothing Then Exit Sub
If Target = "" Then
preValue = "a blank"
Else: preValue = Target.Value
End If
End Sub
Tim Peter
someone changes it. It works fine in the free download and if I paste the
code into a blank workbook. But when I put it into a specific worksheet I
have the code breaks on the format date function. Any help would be great.
Option Explicit
Public preValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("$C$15:$j$15")) Is Nothing Then Exit Sub
Target.ClearComments
Target.AddComment.Text Text:="Previous Value was " & preValue & Chr(10)
& "Revised " & Format(Date, "mm-dd-yyyy") & Chr(10) & "By " &
Environ("UserName")
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Intersect(Target, Range("$C$15:$j$15")) Is Nothing Then Exit Sub
If Target = "" Then
preValue = "a blank"
Else: preValue = Target.Value
End If
End Sub
Tim Peter