Thread: cell protection
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default cell protection

Assumptions.............

Column B is currently unlocked.

Worksheet is currently protected with password of "justme"

Paste this into the sheet module.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 2 Then
ActiveSheet.Unprotect Password:="justme"
n = Target.Row
If Target.Value < "" _
And Target.Offset(0, 1).Value = "" Then
With Target.Offset(0, 1)
.Value = Now
.Locked = True
End With
End If
End If
enditall:
Application.EnableEvents = True
ActiveSheet.Protect Password:="justme", DrawingObjects:=True, _
Contents:=True, Scenarios:=True
End Sub


Gord Dibben MS Excel MVP

On Fri, 15 Dec 2006 09:42:00 -0800, nkidd
wrote:

I am using this script which inserts a time stamp when a user selects an
option from a validated list:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then Target.Offset(0, 1).Value = Now()
End Sub

What I need to do is protect the timestamp so a user cannot alter it
manually. When protect the cells, the script will not run because the
protection blocks it. Is there any way to allow the script to enter the
timestamp, but block users from changing the timestamp? Also, is it possible
to make the script run only once per cell? I dont want the timestamp to
change if the user selects another option in the same cell at a later time if
possible.
Thanks