locking cell

  • Thread starter Thread starter Dominic
  • Start date Start date
D

Dominic

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?
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top