Lenze,
This really useful, I've tried it on a new worksheet and it works perfect.
The problem I have is that I've already got some Vb....
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("P2:P2000")) Is Nothing Then Exit Sub
Application.EnableEvents = False
With Target
.Offset(, 30).Value = Date
.Offset(, 31).Value = Time
.Offset(, 32).Value = Environ("username")
End With
Application.EnableEvents = True
End Sub
And a macro......
Sub Macro2()
ActiveSheet.Unprotect Password:="HALIFAX"
Range("A2:AV1000").Sort Key1:=Range("AP3"), Order1:=xlAscending, Key2:=Range("Q3") _
, Order2:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False _
, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:= _
xlSortNormal
Range("A1").Select
ActiveSheet.Protect Password:="HALIFAX"
End Sub
When I entered the code .....
Option Explicit
Public preValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column <> 16 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 Target.Column <> 16 Then Exit Sub
If Target = "" Then
preValue = "a blank"
Else: preValue = Target.Value
End If
End Sub
This gives me a Microsoft Visual Basic _ Compile error.
Ambiguous name detected; Worksheet_change
(highlighted) Private Sub Worksheet_Change(By Val Target As Range)
Code written as below..
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("P2:P2000")) Is Nothing Then Exit Sub
Application.EnableEvents = False
With Target
.Offset(, 30).Value = Date
.Offset(, 31).Value = Time
.Offset(, 32).Value = Environ("username")
End With
Application.EnableEvents = True
End Sub
Option Explicit
Public preValue As Variant
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If Target.Column <> 16 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 Target.Column <> 16 Then Exit Sub
If Target = "" Then
preValue = "a blank"
Else: preValue = Target.Value
End If
End Sub
Could you please advise.
Regards Jase