+ Reply to Thread
Results 1 to 5 of 5

If statement and countif statement in an array

  1. #1
    Registered User
    Join Date
    01-21-2011
    Location
    Oreong
    MS-Off Ver
    Excel 2007
    Posts
    3

    If statement and countif statement in an array

    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!!
    Attached Files Attached Files

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If statement and countif statement in an array

    Perhaps:

    Please Login or Register  to view this content.
    Incidentally - from what I can tell

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    01-21-2011
    Location
    Oreong
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: If statement and countif statement in an array

    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!
    Attached Files Attached Files
    Last edited by DonkeyOte; 01-26-2011 at 09:07 AM. Reason: removed unnecessary quote

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: If statement and countif statement in an array

    Quote Originally Posted by jntydeman
    Perhaps this problem is related to the formula you provided for the AH column?? When I enter that code, I get some odd numbers
    Typo on my part re: above (misplaced number 1 in range reference)

    Given your latest sample:

    Please Login or Register  to view this content.
    Quote Originally Posted by jntydeman
    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.
    to 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:

    Quote Originally Posted by jntydeman-post1
    if the standard shift is 8 hours, then they only get the one hour lunch when they work 4 or more hours.
    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 >

  5. #5
    Registered User
    Join Date
    01-21-2011
    Location
    Oreong
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: If statement and countif statement in an array

    Quote Originally Posted by DonkeyOte View Post
    Typo on my part re: above (misplaced number 1 in range reference)

    Given your latest sample:

    Please Login or Register  to view this content.


    to 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:



    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 >
    ------------------------------------------------------------------------------------------------------------------------------
    This is now working perfectly as intended! Thank you so much for your assistance!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1