Hello everyone!
I'm currently working on a Macro-enabled Timesheet for my job where the employees can click a button to record the time they come in to work and leave.
I have 4 fields that require a timestamp per day (Clock in for the day, clock out for lunch, clock in from lunch, and clock out for the day).
I also have two additional buttons that are used to mark a particular day as a holiday or vacation.
I'm trying to protect the worksheet so that the employees cannot alter or delete an entry so I unchecked the option to allow users to select locked/unlocked cells, but when I do so it does not allow the user to select the cell where they will have the timestamp recorded (Example below).
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Time In[/TD]
[TD]Time Out (Lunch)[/TD]
[TD]Time In (Lunch)[/TD]
[TD]Time Out[/TD]
[/TR]
[TR]
[TD]06/08/2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]06/09/2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
This is the code that I have for the Clock In/Out button:
Sub EnterTime()
ActiveSheet.Unprotect Password:="password"
Dim DT
'
' MyTimeStamp Macro
'
' Keyboard Shortcut: Ctrl+t
'
DT = Format(Now, "hh:mm:ss AM/PM")
ActiveCell.Select
Selection.NumberFormat = "hh:mm AM/PM"
ActiveCell.Value = DT
ActiveSheet.Protect Password:="password", _
DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
The issue that I am having is that it is not entering the timestamp in the cells that it needs to be entered in. The only way I have been able to make it work is when the sheet is not protected and the user can select the cell where the timestamp needs to be entered, but in doing this the user can still delete the entry.
Does anyone know how I can get this to work?
I'm currently working on a Macro-enabled Timesheet for my job where the employees can click a button to record the time they come in to work and leave.
I have 4 fields that require a timestamp per day (Clock in for the day, clock out for lunch, clock in from lunch, and clock out for the day).
I also have two additional buttons that are used to mark a particular day as a holiday or vacation.
I'm trying to protect the worksheet so that the employees cannot alter or delete an entry so I unchecked the option to allow users to select locked/unlocked cells, but when I do so it does not allow the user to select the cell where they will have the timestamp recorded (Example below).
[TABLE="class: grid, width: 500, align: center"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Time In[/TD]
[TD]Time Out (Lunch)[/TD]
[TD]Time In (Lunch)[/TD]
[TD]Time Out[/TD]
[/TR]
[TR]
[TD]06/08/2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]06/09/2018[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
This is the code that I have for the Clock In/Out button:
Sub EnterTime()
ActiveSheet.Unprotect Password:="password"
Dim DT
'
' MyTimeStamp Macro
'
' Keyboard Shortcut: Ctrl+t
'
DT = Format(Now, "hh:mm:ss AM/PM")
ActiveCell.Select
Selection.NumberFormat = "hh:mm AM/PM"
ActiveCell.Value = DT
ActiveSheet.Protect Password:="password", _
DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
The issue that I am having is that it is not entering the timestamp in the cells that it needs to be entered in. The only way I have been able to make it work is when the sheet is not protected and the user can select the cell where the timestamp needs to be entered, but in doing this the user can still delete the entry.
Does anyone know how I can get this to work?