Office & Productivity Software forum

General discussion

Excel Timesheet formula ~In/Out for Lunch~

I'm using this formula: =(C7-B7+(C7<B7))*24
Of course the columns and rows vary. I want to have a column for lunch. I want a column for the time spent at lunch. Then have the total daily presented with lunch subtracted.


Discussion is locked
You are posting a reply to: Excel Timesheet formula ~In/Out for Lunch~
The posting of advertisements, profanity, or personal attacks is prohibited. Please refer to our CNET Forums policies for details. All submitted content is subject to our Terms of Use.
Track this discussion and email me when there are updates

If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.

You are reporting the following post: Excel Timesheet formula ~In/Out for Lunch~
This post has been flagged and will be reviewed by our staff. Thank you for helping us maintain CNET's great community.
Sorry, there was a problem flagging this post. Please try again now or at a later time.
If you believe this post is offensive or violates the CNET Forums' Usage policies, you can report it below (this will not automatically remove the post). Once reported, our moderators will be notified and the post will be reviewed.
Collapse -
That won't work

In reply to: Excel Timesheet formula ~In/Out for Lunch~

If I understand you properly, you are trying to set up a formula that will calculate how many hours you have worked during the day, "less" the time you spent out to lunch. In which case the formula needs an "out/in" function, not an "in/out" function.

Look at it this way. You have 5 columns, with 5 headers, A5 - B5 - C5 - D5 and E5.

The headers are;

Start time - Begin Lunch - End lunch - End time - Total worked.

In A7 is 08:00
In B7 is 12:00
In C7 is 13:00
In D7 is 17:00
In E7 is the result of the calculation giving you the time you worked, "less" the time you spent at lunch.

In the formula you gave, (C7<B7) always fails because C7 can never be smaller than B7. You cannot end your lunch before you begin it.

Also, the * 24 does not give any meaningful answer. It multiplies any result by 24, but what you want, (if I understand this correctly), is how many hours you worked during the day.

So, you need to take the End time and subtract the Start time, then from the result, take away the time spent at lunch, (which will be the End lunch minus the Begin lunch).

ie, you need D7-A7, gives total time at work, less (C7-B7), gives the time you worked, less your lunch time.

eg E7 =(D7-A7-(C7-B7))

Is this what you mean?

Incidently, each cell needs formatting, under the Numbers tab, to "Number" with 2 decimal places.


Collapse -

In reply to: That won't work

Col B is "In" to work Col C is "Out" finished work. Everything is on 24 hr clock, no am or pm. I would like a col D "Lunch" in minutes or fractions of hour.

B is 0800 arrive at work
C is 1700 leave for the day.
D is 0.50 for lunch
E is 8.5 hours worked

Again I want everything to be on 24 hour clock.


Collapse -
What's your problem?

In reply to: example

I take an empty spreadsheet. Then I fill in

A1: 08:00
B1: 17:00
C1: 0:30
D1: =B1-A1-C1 automatically becomes 8:30

Excel XP does automatic formatting to h:mm (using the Dutch version it's u:mm, but I assume hours are h in English). Anyway, it's automatic, so you can have a look what it should be.

There might be complications with a midnight lunch, but that's not a probable thing to happen.

Hope this helps.


Collapse -
Ahhh, I now see the problem

In reply to: What's your problem?

A light finally shone in my head.

The problem is the figure entered in as the time taken for lunch.

Using Kees example above,

A1 = a time
B1 = a time, but
C1 = a number, (of minutes).

So, each of the cells A1, B1 and C1 must be formatted as either Time, or Custom, (hh:mm).

Then D1 =B1-A1-C1, and D1 must also be formatted as a Time, or as Custom, (hh:mm).

And, as Swisse has said, you must enter each number in the format 00:00, eg hours:minutes, so a 25 minute lunch break becomes 00:25

So, back to your original request,

B7 =time started work, in the format hh:mm
C7 =time finished work in the format hh:mm
D7 =time spent having lunch, hh:mm

then E7 =C7-B7-D7

Highlight all the cells and right click. Select "Format cells"and in the Format Cells dialogue, select "Custom" from the list on the left.

Then, under the "Type" heading on the right, delete any entry, and type in "hh:mm" (without the quotation marks), then click OK.

You could just format the cells as "Time", but this gives results in the hh:mm:ss format.

Hope this helps.


Collapse -

In reply to: Excel Timesheet formula ~In/Out for Lunch~

Hello Mike,
Instead of writing your times for example 0800 for 8 o'clock write it this way 08:00 so that Excel recognizes it as a time value, otherwise it interprets it as just a numerical value and you will just have computation errors.

Now your formula for E7 should look like this :

Hope this is what you meant, otherwise tell me.


Collapse -

In reply to: TimeSheet

Thanks all

Format was what I over looked.

Formated to the time format with other cells all is ok now.

New formula (excel automated the formula) because I put lunch between out from work and daily total.


B is in to work
C is out from work
D is time spent at lunch format is hh:mm

Again thanks all


Collapse -
Glad we could help

In reply to: DOH

and thanks for posting back.


Popular Forums

Computer Newbies 10,686 discussions
Computer Help 54,365 discussions
Laptops 21,181 discussions
Networking & Wireless 16,313 discussions
Phones 17,137 discussions
Security 31,287 discussions
TVs & Home Theaters 22,101 discussions
Windows 7 8,164 discussions
Windows 10 2,657 discussions


This one tip will help you sleep better tonight

A few seconds are all you need to get a better night's rest.