MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Jun 4th, 2002, 11:51 AM   #1
Anne Troy
MrExcel MVP
 
Anne Troy's Avatar
 
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,418
Default

I posted this question, and now cannot find it. Let's see if it's a conspiracy.

I need a formula that will calculate the following cells, as indicated, regardless of the am/pm or date value that the entry has picked up. The entry is displayed only as h:mm and we don't want to make the users enter more than the time to differentiate between am/pm or date.

A1: Time in (no total shows)
B1: Lunch out (time between a1 and b1 shows)
C1: Lunch in (time between a1 and b1 shows)
D1: Time out (total time between a1 and b1, plus total of time between c1 and d1)

Hope this is all the info you need, if not, let me know.
THANKS IN ADVANCE!!
Anne Troy is offline   Reply With Quote
Old Jun 4th, 2002, 12:40 PM   #2
PDuPre'
 
Join Date: Apr 2002
Location: Trussville, AL
Posts: 134
Default

OK. So everything will work fine for you if the user enters their time with AM or PM after it. But, the object is to have them enter the time without AM or PM right?
Difficulty being how should the default change to know that 4:30 is actually 4:30 PM because the prior entry was 12:30 PM and not 12:30 AM. (Assuming you have 3 shifts of users)
Sounds like you will need the user to enter the data into a vba code which will then assign the AM or PM based on previous entries. I think there's a potential for entry error depending on people's shifts.
Philip
PDuPre' is offline   Reply With Quote
Old Jun 4th, 2002, 12:48 PM   #3
Anne Troy
MrExcel MVP
 
Anne Troy's Avatar
 
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,418
Default

Thanks. I'm not at all opposed to a VBA solution! Might need a little help carrying it out...not sure. I don't WRITE code.
__________________
~Anne Troy
Office Articles
Anne Troy is offline   Reply With Quote
Old Jun 4th, 2002, 01:03 PM   #4
Chris Davison
MrExcel MVP
 
Join Date: Feb 2002
Location: Millbank, London, UK
Posts: 1,790
Default

Quote:
On 2002-06-04 05:51, Dreamboat wrote:
I posted this question, and now cannot find it. Let's see if it's a conspiracy.
Dreamboat.... it's in the MVP section
Chris Davison is offline   Reply With Quote
Old Jun 4th, 2002, 01:22 PM   #5
Anne Troy
MrExcel MVP
 
Anne Troy's Avatar
 
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,418
Default

Doh!
__________________
~Anne Troy
Office Articles
Anne Troy is offline   Reply With Quote
Old Jun 4th, 2002, 01:31 PM   #6
PDuPre'
 
Join Date: Apr 2002
Location: Trussville, AL
Posts: 134
Default

If your answer is in the MVP section that's great. I can logically think of what I want to code, but I'm not able to drop it in yet. Thinking that the time entered will always have to be after the previous time. Logically it seems pretty simple. Problem would occur if someone works for more than 12 hours without a lunch break.

Philip
PDuPre' is offline   Reply With Quote
Old Jun 4th, 2002, 01:51 PM   #7
Anne Troy
MrExcel MVP
 
Anne Troy's Avatar
 
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,418
Default

LOL, Philip. My *missing post* was in the MVP section, not the answer.

But I've got a formula solution to share:

=IF(OR(LEN(B4)=0,LEN(C4)+LEN(D4)+LEN(E4)=0),0,IF(AND(LEN(C4)*LEN(D4)=0,LEN(E4)>0),NoLunch,IF(AND(OR(LEN(D4)=0,LEN(E4)=0),LEN(C4)>0),Morning,Morning+Afternoon)))

And it's really ugly, isn't it!!
Anne Troy is offline   Reply With Quote
Old Jun 4th, 2002, 02:58 PM   #8
PDuPre'
 
Join Date: Apr 2002
Location: Trussville, AL
Posts: 134
Default

Dreamboat,

Try =IF(B10="",IF(D10="",0,IF(E10="",0,Afternoon)),IF(C10="",IF(E10="",0,NoLunch),IF(D10="",Morning,IF(E10="",0,Morning+Afternoon))))

Assumes each cell is blank if no time was entered. This will give a time if the employee comes in in the afternoon, but not the morning.
I like how you add the Len(C10)+Len(D10) etc. Never tried that.
Note: where I test for ... E10="",0 ...
the 0 could be replaced with "ERROR" if that will work. That would highlight that they need to input an exit time in order to get paid for that day. Or, could assume a standard day depending on employee type, etc.

I used this in conjunction with data validation that requires each time entry to be after the previous time entry. It will not allow 4:30 AM to be entered if the employee arrived at 7:00 AM. Forces the user to enter either 16:30 or 4:30 PM.

Philip
PDuPre' is offline   Reply With Quote
Old Jun 4th, 2002, 03:20 PM   #9
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 40,228
Default

The entry is displayed only as h:mm and we don't want to make the users enter more than the time to differentiate between am/pm or date.

What follows is an attempt to answer the am/pm issue.

In time-formatted A2 enter:

8:30 [ which reads on the formula bar as: 8:30:00 AM ]

In time-formatted B2 enter:

2:30 [ which reads on the formula bar as: 2:30:00 AM ]

In C2 enter:

=(B2 > A2)*(B2-A2)+(B2 < A2)*(B2+(B2 < A2)-A2-"12:00")

Time-format the formula cell. Note that this is an "improper" way of handling time in Excel [ Hope I don't get annotated for proposing a scheme of abuse. ] However, you can also text-format and right-align the time-entry cells (A2 and B2 above). The formula should still work.

Note. The underlying presupposition is that B2 comes later in time than A2.

Aladin


[ This Message was edited by: Aladin Akyurek on 2002-06-04 09:24 ]
Aladin Akyurek is offline   Reply With Quote
Old Jun 4th, 2002, 03:54 PM   #10
Anne Troy
MrExcel MVP
 
Anne Troy's Avatar
 
Join Date: Feb 2002
Location: Allentown, PA
Posts: 2,418
Default

Thanks anyway, Aladin, but I don't know how to integrate it into my formula that works on all four cells.

Philip: The formula works GREAT. Any way we could have it show the morning hours after the *lunch in* time has been entered? Currently it shows no hours.
__________________
~Anne Troy
Office Articles
Anne Troy is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 05:30 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes