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

Private Sub cmd_time_Click()
ActiveSheet.Unprotect Password:="theword"
With ActiveCell
.Value = Format(Now, "h:mm:ss AM/PM")
.Locked = True
.Columns.AutoFit
End With
ActiveSheet.Protect Password:="theword"
End Sub

I would first unlock all cells before protecting the sheet originally.


Gord Dibben MS Excel MVP

On Tue, 30 Sep 2008 13:41:01 -0700, Dominic
wrote:

Hello friends,
I need to create time sheets for work.. So I have created
a macro for entering the current time. But I do not want anyone to be able to
change the time once it is entered in that column. And any time entered in
the column should always be the current time

Below is my macro for current time
Private Sub cmd_time_Click()
ActiveCell.Clear
ActiveCell.FormulaR1C1 = "=NOW()"
ActiveCell.Value = ActiveCell.Value
End Sub

What do I do?