I am creating a shift schedule for my company. I would like to create a formula (using an array, I believe, is the only way to do this...but if there is another way I would love to hear it!) which will determine if the employee is entitled to a one hour lunch, based on the number of hours worked that day. The problem I am running in to is that the standard shifts vary (either 8 hour shifts or 10 hour shifts).
Basically, I want colum AJ "Lunch Hour" to know if the employee took a one hour lunch that day, based on the total number of hours they worked (AH) and their standard shift (AI). I want it to show a "1" in AJ when the standard shift is 10 hours and the person worked 5 or more hours (you don't get a lunch if you work a half day) OR if the standard shift is 8 hours, then they only get the one hour lunch when they work 4 or more hours.
The way I have the AJ colum calculating now, it cannot distinguish between people who worked a full day and people who worked a half day.
I am using Excel 2007, but I have uploaded a 2003 compatible file to this post.
Thanks!!
Perhaps:
Incidentally - from what I can tellAJ3: =IF($B3="","",COUNTIF($AH3, ">="&$AI3/2)) copied down
AH4: =IF($B3="","",COUNTA($C14:$AF4)) copied down
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
DonkeyOte,
Thanks for your help! The code you have provided for the AJ column is working, sort of. It still can't tell the difference when someone takes a half day. For example, if the number in the AH cell is a 4 (for a person who normally works an 8 hour shift), it still enters a 1 in the AJ column. I have changed the shift in row 14 to give this example.
Perhaps this problem is related to the formula you provided for the AH column?? When I enter that code, I get some odd numbers. I have re-uploaded my file with these changes for you to see.
Thanks again!
Last edited by DonkeyOte; 01-26-2011 at 08:07 AM. Reason: removed unnecessary quote
Typo on my part re: above (misplaced number 1 in range reference)Originally Posted by jntydeman
Given your latest sample:
AH3: =IF($B3="","",COUNTA($C3:$AF3)) copied downto be clear the formulae in AH were wrong but regards the above based on your OP (below) 4 hours for an 8 hour shift would still warrant a lunch break:Originally Posted by jntydeman
If you're saying now that lunch is included only where ee works greater than 1/2 shift as opposed to greater than or equal to 1/2 shift you should adjust the operator accordingly in the AJ formula: from >= to >Originally Posted by jntydeman-post1
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks