Timesheet: easy entry, then calculate

Mahpie

New Member
Joined
Feb 18, 2016
Messages
3
Hi lovely Excel forumers. I've searched, but I keep finding things that are quite different from what I want to do.

I am making a timesheet entry form.

I want people to be able to enter the time in 4 key presses (e.g. for 12:45, I just want them to be able to type 1245, and not need to mess about entering a colon in the middle).

To get that to work (for some value of "worked"), I changed the format of the cells to a custom number type: 00\:00

But, of course, when it goes to calculate 1200 - 0830 (to work out hours worked in the morning) it gets 03:70. Which is bad.

So data entry is fine - it looks great! But I'm guessing I need to convert those numbers back into times before I can do the "end time minus the start time = hours worked" calculations, right?

So assuming the users aren't dopes and actually enter valid times, is there a way I can convert times in the format of 00\:00 into actual hh:mm format?
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

jorismoerings

Well-known Member
Joined
Jul 4, 2014
Messages
1,284
Hi and welcome to MrExcel,

With changing the number format to create an easy input you've changed the actual input from time to general number and hence the calculation of 12:00 -/- 08:30 will in fact be 1200-830.

You were on the right track with the remark to convert the numbers back into time.

try this:
<b></b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #BBB"><colgroup><col width="25px" style="background-color: #DAE7F5" /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #DAE7F5;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="text-align: right;;">08:30</td><td style="text-align: right;;">12:00</td><td style="text-align: right;;"></td><td style="text-align: right;;">8:30:00</td><td style="text-align: right;;">12:00:00</td><td style="text-align: right;;">3:30:00</td><td style="text-align: right;;"> 3,50 </td></tr></tbody></table><p style="width:3,6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #BBB;border-top:none;text-align: center;background-color: #DAE7F5;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">D1</th><td style="text-align:left">=TIME(<font color="Blue">LEFT(<font color="Red">A1,IF(<font color="Green">LEN(<font color="Purple">A1</font>)=3,1,2</font>)</font>),RIGHT(<font color="Red">A1,2</font>),</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">E1</th><td style="text-align:left">=TIME(<font color="Blue">LEFT(<font color="Red">B1,IF(<font color="Green">LEN(<font color="Purple">B1</font>)=3,1,2</font>)</font>),RIGHT(<font color="Red">B1,2</font>),</font>)</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">F1</th><td style="text-align:left">=E1-D1</td></tr><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">G1</th><td style="text-align:left">=(<font color="Blue">E1-D1</font>)*24</td></tr></tbody></table></td></tr></table><br />
Cells D1,E1`and F1 and cell with a time format [hh]:mm

Hope this helps.
 
Last edited:

Mahpie

New Member
Joined
Feb 18, 2016
Messages
3
Thank you so much for the very quick reply. I'll give that a go on Monday and report back!
 

Mahpie

New Member
Joined
Feb 18, 2016
Messages
3
Hi and welcome to MrExcel,

With changing the number format to create an easy input you've changed the actual input from time to general number and hence the calculation of 12:00 -/- 08:30 will in fact be 1200-830.

You were on the right track with the remark to convert the numbers back into time.

try this:
ABCDEFG
108:3012:008:30:0012:00:003:30:00 3,50

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
D1=TIME(LEFT(A1,IF(LEN(A1)=3,1,2)),RIGHT(A1,2),)
E1=TIME(LEFT(B1,IF(LEN(B1)=3,1,2)),RIGHT(B1,2),)
F1=E1-D1
G1=(E1-D1)*24

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>


Cells D1,E1`and F1 and cell with a time format [hh]:mm

Hope this helps.


It worked! Thanks heaps.

I did have to allow for errors, since blank entries gave me the dreaded #VALUE! all over the place, which messed up some of the calculations. So the code I used in the end was:

=IFERROR(TIME(LEFT(A1,IF(LEN(A1)=3,1,2)),RIGHT(A1,2),), 0)

...and formatting took care of the rest.

Thanks again!
 

Watch MrExcel Video

Forum statistics

Threads
1,129,754
Messages
5,638,170
Members
417,011
Latest member
Amaden95

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
Top