Excel - count WORK days in each month between two dates - excel-formula

I'm trying to figure out the number of workdays between two dates for each month. I have found this answer already and it works just fine for the days.
I would now like to know, how many workdays there are in each month. Meaning (again based on the linked answer), I'm here:
and would like to get to this here:

There is a function called Networkdays. You can find details here and here. You will need to know which holidays you have in-between.
I usually generate a list of all dates in a calendar year (or download it) and then mark the holidays I want to exclude with an x.

You are looking for the NETWORKDAYS function.
Based on the linked result, something like the below should work (and be easy to modify based on how your sheet is set up):
=IF(
IF(C2$3>$B2, NETWORKDAYS(B$2+1, $B2), NETWORKDAYS($A2, C$2)-SUM($B3:B3))<0,0,
IF(C2$3>$B2,
NETWORKDAYS(B$2+1, $B2),
NETWORKDAYS($A2, C$2)-SUM($B3:B3)))
For example:

Related

Is there a way to find the time between 2 dates after subtracting in excel?

I am given this task to complete
"What is the average time for a project to go to 3-Offered per year for the years 2016, 2017, and 2018? Use the formula # Days = [Date Offered] - [Start Date].
Only projects where [Project Template] = "Pre-Approval" will have an offered date, no need to include Fast Track projects in the data."
my current function I am trying to use is
=AVERAGE(IF((B:B="Pre-Approval")*(C:C="3-Offered")*(YEAR(D:D)=2016),E:E-D:D)) but I am getting the #VALUE! and I'm not sure why.
I will link a screenshot of some of the data used for this task.
[Column D is the start date and Column E is the Offered Date]
I think it is easier if you break down the problem into smaller pieces.
First, I would separate the years from the offered date. On a different column, e.g. Year, I would apply =YEAR() for every item in your Offered Date column.
Second, I would take another column, call it Diff, and apply =OfferedDate-StartDate.
Then, for each individual year I would apply =AVERAGEIFS(diff_column_range, year_column_range, "3-Offered", year_column, required_year)
I have an example for you here: https://1drv.ms/x/s!AhMbe-MPmuFCggjutWepn-QtMri4?e=CxpTCW
Let me know if this works for you.
Cheers!

Excel count number of dates (in rows) which fall under a predetermined period

So i have been playing with Excel for a while, and one thing led to another, i wanted to try this: How would i calculate the instances of dates (such as below) in one sheet
And count which of those dates fall under the 30/60/90 day period (such as below) I'm looking to see if i could have a final tally up the number of instances of dates which fall below 30/60/90 days to the current date in another sheet.
Using the table example gave that i would know that 2 dates fall under the 30/60 days period, and one fell under the 90 days period
Is there a solution to my predicament?
Edit: More accurate question
Use nested IF() function.
=IF(TODAY()-B2<=30,30,IF(TODAY()-B2<=60,60,IF(TODAY()-B2<=90,90,"Other period")))
Or try IFS() if you have Excel-365.
=IFS(TODAY()-B2<=30,30,TODAY()-B2<=60,60,TODAY()-B2<=90,90)
Another option is-
=XLOOKUP(TODAY()-B2,{30,60,90},{30,60,90},"Other Period",1)
You could try:
Formula in E2:
=SUMPRODUCT(--(CEILING(D$6-B$2:B$6,30)=D2))

How to filter data of last record of each week

I have a big data set of daily selling value of a particular ITEM. I want to know what was the price of ITEM on the last day of each week. Typically the last working day is Friday but if you don't have data for Friday then we need to get the previous working day data (Thursday).
Monday is considered the First day of week.
My Data looks something like this:
Data is in cells A2:C13.
My expected output is shown below:
Please help with VB macro or even simple excel formula.
You may want to try using a formula using the LOOKUP function, to search the list from bottom to top.
Afterward, a combination of INDEX and MATCH may get you on the right path as well.
Edit: I realize now that I was leading you astray because I thought you were asking something else! The most straightforward way I can see is as follows:
use WEEKDAY() to pull out the weekday values (as you did), except leave the values as numbers (with 1 being Sunday and 7 being Saturday).
Check each of these days to see if it precedes (i.e. has a lesser value) than the day above it. If not, we know that the week started over, and that cell is the last day of the week. Therefore, display its value.
Of course, this assumes that there are no Saturdays in your data - otherwise, Saturday would be listed as the end of the week. If you're crafty you can fix this dilemma though!
Thanks, Tyler.
Your suggestion helped me a lot in putting efforts in the right direction.
The way I did is as follows:
First I sorted my data in decreasing order of date so that I can have all the latest data at the top.
Range("AW4:BE999999").Sort Key1:=Range("BC4:BC999999"), order1:=xlDescending, Header:=xlYes
From Date created a string of "YEAR"&"WEEKNUM". This way I was able to group all the days in a specific week. Formula Used is:
=(TEXT(BC5,"yyyy"))&(TEXT(WEEKNUM(BC5),"00"))
Then I gave a unique Number to each record. The best way I could think of is to give the row number where record belongs.
=ROW(AY5)
Now using VLOOKUP function I got all the records matching string I have created in step 2
=VLOOKUP(AZ5,AZ:BD,5,FALSE)
I applied the above formula to get all the columns that I need.
Now I removed all the duplicate rows using below formula:
Cells.RemoveDuplicates Columns:=Array(1)
Now the remaining rows are the expected rows.
There may be a better way to do this but this is my first time with excel macro and formulas, so feeling happy.
Please comment other better ways to do this. It's always good to keep on improving our work.

Count entries for current month

So I want to count how many entries have been filed in the month of July. Could someone help me how to do that so every month when the new data is added it automatically updates and gives new data for each month. I know I need to use combination of =CountIfs, =today, Month, =Year but not sure how exactly to formulate that.
Use SUMPRODUCT()
=SUMPRODUCT((YEAR($A$1:$A$100)=YEAR(TODAY()))*(MONTH($A$1:$A$100)=MONTH(TODAY())))
This will count every month that is the same as the month today.
Here is the COUNTIFS version for the original question
=COUNTIFS($A$1:$A$100,"<="&EOMONTH(TODAY(),0),$A$1:$A$100,">"&EOMONTH(TODAY(),-1))
or
=COUNTIFS($A$1:$A$100,"<"&DATE(YEAR(TODAY()),MONTH(TODAY())+1,1),$A$1:$A$100,">="&DATE(YEAR(TODAY()),MONTH(TODAY()),1))
You might be thinking of something like =countifs(month($A$1:$A$100),month(today)) but unfortunately it doesn't work - the first value in the countifs has to be a range and you can't use a function here so it has to be done with a SUMPRODUCT as in Scott Craner's answer.

Sharepoint, Calculated column, IF function and date

I am trying to add a calculated column.
I have a date column containing the date a meeting is scheduled. From this column I need a code which can return if the meeting is scheduled in Q1, Q2, Q3 or Q4. I have a static code looking like this:
'=IF(Date<40269;"Q1";"Q2-4")' (40269 is the 1. April 2010 and Date=date-column)
But I need somekind of dynamic code which can calculate the same thing next year as well, without someone having to change the number(40269). I need something like this:
'=IF(Date<01-01-&year(today);"Q1";IF(Date<01-04-&year(today);"Q2";IF(Date<01-07-&year(today);"Q3";"Q4")))'
But Sharepoint will not accept a date written like this 01-01-2010, it needs to be a number eg. 40269. The above code will only work correct for the present year, but thats all-right, since I will only use data from the present year.
Can anyone help me?
Ahhhh... It was easier than I had anticipated. I used this function:
=IF(MONTH(Date)<4;"Q1";IF(MONTH(Date)<7;"Q2";IF(MONTH(Date)<10;"Q3";"Q4")))
Date is a column containing the date of the meetings. month() returns the number of the month. E.g., march=3.

Resources