Time Stamp

sm8392

New Member
Joined
Jun 11, 2018
Messages
10
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).

DateTime InTime Out (Lunch)Time In (Lunch)Time Out
06/08/2018
06/09/2018

<tbody>
</tbody>

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?
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
i tried the macro in post 3 and working perfectly, however, when i double clicked again the cell, it replaces the original date and time. how can i totally lock the cell
 
Upvote 0
Unfortunately, you can't do what you want using this approach. If you explain in detail what you are trying to do using a few examples, maybe we can try a different approach.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,055
Latest member
excelhelp12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top