Calculate annual leave between two dates in Excel - excel

This task seems easy enough yet I just can't figure a way of doing this without resorting to vba.
All I need is to know the number of hours an employee has used up on annual leave, based on a start and end date, and their hours of work.
To be more clear, this example shows one employees contracted hours from Monday to Sunday i.e. they work only Weds, Thurs, and Friday, for 7.5 hours each day.
Below shows the start and end date that the employee has chosen to take for annual leave. I need to calculate, based on their contracted hours, how much annual leave is used between the two dates. The answer would be 45 hours in this case.

Here's another approach - I've expanded the days between the start and end dates into an array then used the resulting day numbers to offset into the days of work range
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1)))
If you had a list of holiday dates somewhere (say in I3:N3) you could exclude them as follows
=SUMPRODUCT(N(OFFSET(A3,0,WEEKDAY(ROW(INDIRECT(A6&":"&B6)),2)-1))*ISNA(MATCH(ROW(INDIRECT(A6&":"&B6)),I3:N3,0)))
- it is a bit long-winded but the only way I can think of at the moment.

Related

Excel - SUMIF Function

I made a worksheet covering meal expenses for a set period of time (01-08-2020 until 31-08-2020.)
The company will pay up to 75kr, Monday-Friday.
The list covers expenses 7 days a week, If the amount is greater than 75 on Monday-Friday, I have to pay the extra expenses. (This I have figured out correctly). Saturday and Sunday I have to pay fully.
So my question is, how can I sum this and exclude Saturday and Sunday?
Attempt 1:
I tried this formula (Norwegian excel. Summerhvis = SUMIF. Lørdag = Saturday):
=SUMMERHVIS(B2:B32,"<>lørdag", G2:G32)
It seems to be partly correct however, I miss Sunday, how can I add Sunday to this equation?
Attempt 2:
I used this formula:
=SUMMERHVIS(B2:B32,B2:B6,G2:G32)
It gave the correct answer but the answer was layered in 5 rows. I then summed this in P8.
Where I want the answer is in G32. So in G32 I wrote =p8.
It must be an easier way of doing this?
You can use SUMPRODUCT and the WEEKDAY function:
=SUMPRODUCT((WEEKDAY(A2:A32,3)<5)*G2:G32)
According to the Microsoft function translator, this might be, in Norwegian:
=SUMMERPRODUKT((UKEDAG(A2:A32;3)<5)*G2:G32)
If you really want to use SUMIF and your text days, one way would be (in English):
=SUM(SUMIF(B2:B32,{"Monday";"Tuesday";"Wednesday";"Thursday";"Friday"},G2:G32)),
or, if your weekday days are in b4:b8:
=SUM(SUMIF(B2:B32,$B$4:$B$8,G2:G32))
but I'd advise against it as it would only work in the language of the text days of the week. Also, I note your days of the week don't seem to match up with what the days of the week were in the US. For example, here 1 Aug 2020 was a Saturday, so another possible cause for error (unless I am not understanding the dates correctly).
The above is the same as summing five separate SUMIF equations, each for a desired day of the week.

Turnaround Time excluding Weekends

Hi i need to get the turnaround time of this columns excluding the weekends. I tried to subtract it but without the excluding the weekends, so i am not successful to get the right turnaround time needed. Please help me to get the right formula for excluding the weekends of this sample. Thanks
As you can see here, this is the data that i need to get the TURNAROUND TIME, so what i did is column N subtract to column M.
This is the formula i used to see the results with correct format but i want to have a result which will have a exclusion of weekends but i don't know how to do it.
How about using the following formula, this will calculate the Work Days between two dates:
=NETWORKDAYS(N2,M2)
Since the comments in the old answer have grown - to the extent that the question needs editing to include all of the "additional" requirements (and there are various reason why these chameleon questions are often frowned upon. For any more "tweaks", raise a new question.) - I am posting the updated code here.
First: Since NETWORKDAYS counts from the Start of the first day to the End of the Last day, it tends to add an "extra" day. To fix this, we need to remember to subtract the first-part of the first day (midnight to start time) and the last part of the last day (end time to midnight) - but only if they are each Workdays.
=NETWORKDAYS(M2,N2)+IF(MOD(WEEKDAY(N2),7)>1,MOD(N2,1)-1,0)-IF(MOD(WEEKDAY(M2),7)>1,MOD(M2,1),0)
Next, was the requirement to exclude Holidays. IMPORTANT! This requires that you have a Worksheet called "Holiday Sheet", with a list of the Dates of your Holidays in Column A.
We use ISERROR(MATCH(..)) as a check for "Not in the list", and NETWORKDAYS accepts the list the third, optional, argument/parameter
=NETWORKDAYS(M2,N2,'Holiday Sheet'!$A:$A)+IF(AND(MOD(WEEKDAY(N2),7)>1,ISERROR(MATCH(N2,'Holiday Sheet'!$A:$A,0))),MOD(N2,1)-1,0)-IF(AND(MOD(WEEKDAY(M2),7)>1,ISERROR(MATCH(M2,'Holiday Sheet'!$A:$A,0))),MOD(M2,1),0)
The last "extra" requirement was to calculate this as Working Hours, with a workday running from 07:00 to 16:00 - a 9 hour day. To start, multiply NETWORKDAYS by 9 hours (TIME(9,0,0)), and then remember to remove the first-part of the first day (corrected for working hours) and the last part of the last day (also corrected for working hours).
We can use MEDIAN to get the middle number from 3 values, so that we never use a time before 07:00 or after 16:00
=TIME(9,0,0)*NETWORKDAYS(M2,N2,'Holiday Sheet'!$A:$A)+IF(AND(MOD(WEEKDAY(N2),7)>1,ISERROR(MATCH(N2,'Holiday Sheet'!$A:$A,0))),MEDIAN(TIME(7,0,0),MOD(N2,1),TIME(16,0,0))-TIME(16,0,0),0)-IF(AND(MOD(WEEKDAY(M2),7)>1,ISERROR(MATCH(N2,'Holiday Sheet'!$A:$A,0))),MEDIAN(TIME(7,0,0),MOD(M2,1),TIME(16,0,0))-TIME(7,0,0),0)

Excel Formula for calculating time in round numbers with hours text

I'm trying to figure out a way to create an excel spreadsheet that will allow me to keep track of how many hours I've earned per each paid holiday my company offers, then keep track of how many hours I've used and what's remaining. But I'm unsure how to calculate this properly.
I could easily do the math my self as it's a simple lay out, but I'm trying to find a way that will just let me enter the numbers for earned and used and walk away from anything else.
What I'm trying to do is the follow:
Have multiple sections. In the first section it'll be my holidays. So in like Column A, working down I'd have New Years, Memorial Day, July 4th, etc. Column B working down would be time earned. But this would be labeled in each cell as "8 Hrs" or "4 hrs". Column C would be time used in the same format "4 hrs" "8 hrs". Then Column D would simple be hours remaining.
Now in the second section I'd have holiday hours earned, which is 2 weeks. Not too sure how to lay it out, and then I still have my sick days, but not sure if I should include that in section 2 or not with the vacation time.
I'd like a way to be able to simply Calculate B2 - C2 = D2. So 8 Hrs - 4 Hrs = 4 Hrs (to show 4 Hrs remaining for each line item.)
Problem is I'm unsure how to calculate remaining time simply because of the Hrs suffix. And with that I also can't calculate total time still remaining, both for holiday hours earn and vacation/sick hours.
Yes, it's easier for me to track it as 8 Hrs rather than 1 day, etc.
Any advice on how to formulate this. Or if anyone knows of a premade template that fits this type of scenario, that I could then just take and integrate into my own spreadsheet.
Sorry if this is confusing in any way.
Also, As I'm no excel wizard, unsure if this is relevant or not, but I'm using Excel 2016, as part of the Office suite.
Another option is to just leave the number as it is and label the column accordingly. Do you really need to see "hrs" in every cell when you know you are tracking hours?
Use a custom number format of,
[>1]0 \H\r\s;[=1]0 \H\r_);0 \H\r\s;[Red]#
... and treat all hours as integers.

Excel function to create due dates that land on a business day

I'm stuck creating a formula that will calculate days before the end of the month then adjust to make sure it is a business day. For example: 30 days before 6/30/2015 is 5/31/2015 which is a Sunday. I need that to adjust to the Friday before.
I'm working on finding the due dates of a number of documents that are due a certain number of days before another date. For example: documents are due 30 days before the last day of the month. However, the number of days varies and the due date needs to fall on a business day (Monday-Friday). Sometimes it's 30 days, sometimes it's 60 days, sometimes it's 30 calendar days + 5 business days, etc.
I've been able to calculate 30 days + 5 business days with the following formula:
=workday(start_date-30,-5)
Any ideas how to adjust this so that I can just have the due date be 30 calendar days before a certain date but also always be a business day?
Using WORKDAY you can use a formula like this:
=WORKDAY(A1+B1+1,-1)
where A1 is your start date and B1 the number of days to add.
You probably need to write a macro function or maybe some nested IF statements in your cell's formula.
Take a look at http://www.mrexcel.com/forum/excel-questions/481558-round-date-nearest-workday.html
That solution moves forward to the nearest workday, but the principle is sound: just subtract instead of add.

Excel - Find if worker has worked certain OT if weekday and or Sunday

I have a worksheet with days running along the columns, within each day there are different hourly categories, 130%, 150%, 200% and 215% etc, there are other categories within each day, but these are not to be included. (Can't post Image as new, can email?)
If a worker works over 3.5 hours in any of these categories they get an extra lunch, except on Sunday's where they must work 4 hours.
I've been using countif's to check each day over 3.5, and another column for Sunday's.
The weekday and Sunday can be combined into the same column as the lunch price is still the same, just number of working hours different.
The main problem is I have to adjust the countif's every month, I want something that will look at days of the week and/or sunday's and check without adjusting every month.
Have been trying to get my head around sumproduct with countif!
Any help, very much appreciated.
Thanks!
Since you have not mentioned what is where this might take some adjustment, but may get you started:
=IF(SUM(B3:G3)>=IF(WEEKDAY(B$1)=1,4,3.5),"lunch","no lunch")

Resources