Excel Timesheet

trigirl

Board Regular
Joined
Sep 13, 2007
Messages
87
I have an Excel timesheet, and I am wondering if there is a way to have the timesheet default to PM after 12 noon, so the employees dont have to put in PM, they would just put their time and the sheet would default it to PM.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Need more details!
How do you enter time? Macro or button?
The more details you can give would help!

Michael
 
Upvote 0
The employees enter their time manually. The problem we having is that they forget to put AM/PM and it messes up our other reports, so I wanted to make it as fool proof as possible.
 
Upvote 0
If you don't have anyone crossing midnight or working longer than 12 hours at a stretch, your "hours worked" formula can check to see if the stop time is before the start time, adding 12 hours. If start time is in Col B, stop time is in Col C and hours worked is Col D, the D2 would have:
Code:
=24*(C2-B2+IF(C2<B2,0.5,0))
or
Code:
24*MOD(C2-B2,0.5)

I suppose you could put some code into the Worksheet_Change event, and have it check the NOW function, adding 0.5 if the current time is later than 1:00 PM. I have very little experience with event-handling, so this is affirmation of concept. Any event-wizards here today?
 
Upvote 0
there are a number of way to get this done.

1 Go to military time
2 Create a combo box with only the times you have in the combobox

can you give a sample of the times: Do you go by minutes, 5 minutes, etc.

We go by Quarter hours, so I created a combobox that only has times entered in quarter hours.

Michael
 
Upvote 0
Create a button using the Forms Menu.

Type in "EnterTime"
Then create. Just copy and paste this code
Code:
Sub EnterTime()
    InpBx1 = InputBox("Enter the hour you want.")
    InpBx2 = InputBox("enter the minutes you want.")
    InPBx3 = InputBox("Enter AM or PM ")
    Application.ActiveCell.Value = InpBx1 & ":" & InpBx2 & ":" & "00 " & InPBx3
End Sub

The user will be asked the hour.... the minutes..... then AM or PM


Michael
 
Upvote 0
Ok this button works great, but I do have question. I want to lock the cells so that the only way they can enter time is by clicking the button, but when I lock the cells it sends a message saying it cant update the cells because it is locked. Is there a way to make this the button the only way to enter time?
 
Upvote 0
Ok
Try this:
Sub EnterTime()
ActiveSheet.Unprotect
InpBx1 = InputBox("Enter the hour you want.")
InpBx2 = InputBox("enter the minutes you want.")
InPBx3 = InputBox("Enter AM or PM ")
Application.ActiveCell.Value = InpBx1 & ":" & InpBx2 & ":" & "00 " & InPBx3
ActiveSheet.Protect
End Sub
Michael
 
Upvote 0
Ok, we are almost there. This has it prompt to put in the password to unprotect the sheet, but the employees don't know the password. Is there a way to have the script put in the password?
 
Upvote 0

Forum statistics

Threads
1,215,327
Messages
6,124,287
Members
449,149
Latest member
mwdbActuary

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