ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   locking cell (https://www.excelbanter.com/excel-programming/417905-locking-cell.html)

Dominic

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

Gord Dibben

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?



John

locking cell
 
there is a sample timesheet workbook you can download for free at this site
which may give you some development pointers.
http://spreadsheetpage.com/index.php/file/C35/P20/
--
jb


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



All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com