B
Ben Dummar
Hi,
I am trying to auto-set the current date in a cell when data is modified in
a corresponding cell.
The cell that the date is being inserted into is locked so it works great
until I protect the sheet. Once the sheet is protected it will no longer
enter the date into the locked cell. How can I modify the code below to allow
it to enter the date even when the cell it is trying to enter it into is
locked?
"Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim R As Long
R = Target.Row
On Error GoTo ErrHandler
Application.EnableEvents = True
If Not Intersect(Range("L2:m20"), Target) Is Nothing Then
Range("L2:M20").Sort Key1:=Range("L2") '<<== CHECK RANGE
End If
If Target.Column <> 2 Then Exit Sub
If Target.Row = 1 Then Exit Sub
Target.Offset(0, 2).Value = Date
ErrHandler:
Application.EnableEvents = True
End Sub
"
Thanks,
Ben
I am trying to auto-set the current date in a cell when data is modified in
a corresponding cell.
The cell that the date is being inserted into is locked so it works great
until I protect the sheet. Once the sheet is protected it will no longer
enter the date into the locked cell. How can I modify the code below to allow
it to enter the date even when the cell it is trying to enter it into is
locked?
"Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim R As Long
R = Target.Row
On Error GoTo ErrHandler
Application.EnableEvents = True
If Not Intersect(Range("L2:m20"), Target) Is Nothing Then
Range("L2:M20").Sort Key1:=Range("L2") '<<== CHECK RANGE
End If
If Target.Column <> 2 Then Exit Sub
If Target.Row = 1 Then Exit Sub
Target.Offset(0, 2).Value = Date
ErrHandler:
Application.EnableEvents = True
End Sub
"
Thanks,
Ben