Excel workdays formula - excel-formula

I have an excel 2010 formula that calculates delivery days on-time, late or early which is good but I need workdays, anyone know how to convert this formula?
=IF(AL16="","",TEXT(AL16-P29,"0 ""Day(s) Late"";0 ""Day(s) Early"";""On Time"""))

Since we do not have your data sheet, it is not easy to understand what the formula is doing but assuming that AL16-P29 part is an ordinary date difference, you should ammend that part to NETWORKDAYS(P29, AL16) in order to find how many workdays are there between these two dates.
As a result your formula s/b:
=IF(AL16="","",TEXT(NETWORKDAYS(P29, AL16),"0 ""Day(s) Late"";0 ""Day(s) Early"";""On Time"""))

Related

Excel formula to count date ranges

I need to come up with a formula that will count the number of rows of a date column. I need greater than 365, 300-365, 299-230 ect all the way down to 30 days. One formula for each will be perfect and as long as I can figure out the first couple, I can get the rest. Help is much appreciated.
The date format in the excel table is: 9/1/2021
A year or older. Seems this may be close but it's giving an error
=COUNTIF(A1:A1000,">="=DATE(YEAR(=TODAY()-1)))
=COUNTIFS(A1:A1000,">="=DATE(DAY(=TODAY()-364)),A1:A1000,"<="=DATE(DAY(=TODAY()-300)))
More than 365 days ago:
=COUNTIF(A1:A1000,"<="&TODAY()-365)
300-365 days ago (need countifs in order to do multiple criteria)
=COUNTIFS(A1:A1000,">="&TODAY()-365,A1:A1000,"<="&TODAY()-300)
Think about using Frequency - this works in most versions of Excel, but has to be array-entered in non-365:
=FREQUENCY(A2:A1000,TODAY()-C2:C11)
The bin values can be entered into the sheet as below or expressed as an array constant in curly brackets. Note that each bin includes values less than or equal to the corresponding cut-point, so the first value is 366:
If all bin sizes were equal, you could use Sequence in Excel 365 to generate the bin ranges.

Excel a function as SUMIFS criteria

I have a series of dates and values:
8.12.2018 12
5.2.2019 32
15.7.2019 89
I would like to use something like (SUMIFS(YEAR(A1:A3);2018) but it's not allowed.
I know, I could extract the year in a separate column, but here I want to ask, if it's possible inside the sumifs function?
Although I thought you couldnt, it has proven by #forwardEd, you can alter criteria in such a way to use SUMIFS, however, you could also look into SUMPRODUCT for this exercize:
=SUMPRODUCT(--(YEAR(A1:A3)=2018),B1:B3)
Assuming your dates are valid excel dates and not dates as strings/text then you can use the SUMIFS formula for a year as follows:
=SUMIFS(B1:B3,A1:A3,">="&date(2018,01,01),A1:A3,"<="&date(2018,12,31))
Basically the formula is saying sum all the values in B1:B3 where the date in A1:A3 is greater than or equal to the first day of the year AND less than or equal to the last day of the year. I choose to write the date using the date function as it is easier to recognize than the integer format of the date. If you want to write just the year as a criteria in say cell c2 then replace 2018 in the above formula with c2.
UPDATE
I have not tested it but since the default for a date without time is 00:00:00 it would mean the formula above would cut off December 31 with almost any sort of time associated with it. Therefor the better cut off would be less than January 1st of the following year instead of less than or equal to December 31st. As such you could revise the above formula to:
=SUMIFS(B1:B3,A1:A3,">="&date(2018,01,01),A1:A3,"<"&date(2019,01,01))
or
Where C2 is the year as an integer
=SUMIFS(B1:B3,A1:A3,">="&date(C2,01,01),A1:A3,"<"&date(C2+1,01,01))
Alternative approach (a little bit less elegant solution, but might be more clear to less advanced users):
=SUMIFS(B1:B4,A1:A4,">="&"01/01/2018",A1:A4,"<="&"31/12/2018")

SUMPRODUCT several ifs

I´ve spent a lot of time with a formula in Excel and I´m still blocked. I hope you can help me.
I have a table in Excel with several values as shown in this
screenshot.
What I´m trying to extract is the number of Fruits sold in a specific month. That is, how many lemons were sold in January 2016, for example. This is the formula I´m using:
=SUMPRODUCT((B3:B38=E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
But the result is #N/A as seen in the screenshot.
What Am I doing wrong? Any help, please?
Thanks a lot in advance!
You can use arrays in excel to get this answer
{SUM(IF(MONTH(F$3&"1")=MONTH($A$3:$A$150),IF($E4=$B$3:$B$150,$C$3:$C$150,0),0))}
You can use this Sumproduct formula which uses array logic:
SUMPRODUCT((MONTH($A$3:$A$38)=MONTH(TEXT(G$2,"MMM")&1))*($C$3:$C$38=$F4)*
($D$3:$D$38))
Sumproduct Demo
Part of your problem is your ranges are not equal in length. B3:B38 has to be the same number of rows as $A$3:$A$150 and C3:C150. When rows are not equal things blow up on you.
=SUMPRODUCT(($B$3:$B$150=$E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
if you change your header row to be actual excel date format, and then change the cell display format to just show the month (as suggested by csanjose), then you can adjust your sumproduct formula as follows and copy to all cells in your table.
=SUMPRODUCT(($B$3:$B$38=$E4)*(MONTH($A$3:$A$150)=Month(F$3))*(YEAR($A$3:$A$150)=Year(F$3));$C$3:$C$150)
Fill your month-row with the last day of each month, then apply date format to show only month name.
The formula you should use is, for example, in g8:
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&G$3;$A:$A;">"&F$3)
First column "F" doesn't have a column on the left to compare, so you can put a date in E3 or change a bit the formula (example of F8):
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&F$3;$A:$A;">2015/12/31")
Take a look at the result
If you don't want to use a pivot table, you can use this formula to get what you need:
=SUMPRODUCT(($B$3:$B$150=$E3)*(MONTH($A$3:$A$150)=1)*(YEAR($A$3:$A$150)=2015)*$C$3:$C$150)
Then drag-fill the cell to copy it to every month column (just make sure you change the month number in the formula (and year if you're doing that too)), and then drag-fill down the columns.
That should work pretty food good :)
Good Luck!

Sumif Amounts Based on Months for Multiple Months

I have excel data in the following format
Date Amount
01-Jan-16 23.94
12-Jan-16 17.96
26-Jan-16 32.92
03-Feb-16 38.90
20-Feb-16 62.27
26-Feb-16 45.89
I would like to sum the amount field for specific months, that is I would like to sum up the amount in January and also in February separately.
This is the code I have tried thus far which I found in a previously asked question (see Excel Formula to SUMIF date falls in particular month).
=SUM(IF(MONTH(A:A)=1,B:B,0))
It works for January but when I change 1 to 2 it returns zero.
=SUM(IF(MONTH(A:A)=2,B:B,0))
Would sumifs work better?
Here are two other ways of doing it:-
=SUMPRODUCT((MONTH(A2:A10)=1)*B2:B10)
and
=SUMIFS(B2:B10,A2:A10,">="&DATE(2016,1,1),A2:A10,"<"&DATE(2016,2,1))
Change as necessary to get totals for other months.
I have put the results next to the original array formula in this screen shot:-
Use specific range rather than full column. You must use the formula as array formula.
=SUM(IF(MONTH($A$2:$A$1000)=1,$B$2:$B$1000,0))
Press CTRL+SHIFT+ENTER to evaluate the formula as array formula.

date dependent cell reference

I was hoping someone might be able to point me in the right direction, I'm trying to automate a section of a spread sheet which shows a persons planned hours of work against the hours they actually did. The data is sourced from a worksheet which is broken down into months and departments.
Is there a way to get the reference table on the main dashboard to vlookup/index a certain column dependent on the computers date?
I.E. for May it will look in the planned and actual hours column for may and then in June it will search the June column for the same data.
Normally I would post some code but I'm not even sure where to begin on this one.
You mention VLOOKUP in you question.
To use this in VBA use, WorksheetFunction.Vlookup(), but it seems you could avoid VBA altogether if you wanted. Here are some formulas of interest:
If you want to search months by the current date, you can use this kind of vlookup (or MATCH() or HLOOKUP() if these are columns as you indicate)
=VLOOKUP(TEXT(TODAY(),"mmmm"),Range,1,FALSE)
Use "mmm" if you use 3-letter months
If months are in static column number can be taken from using the MONTH() function.
=MONTH(TODAY())
"index a certain column dependent on the computers date?"
=TODAY() gets computer's date.
I would tend to use MATCH() to get the months column (in this example I've assumed months are in row 1)
=MATCH(TEXT(TODAY(),"mmmm"),1:1,0)
You can then use INDIRECT() to match a specific month column and department row (if in a 2D format), or SUMIFS() with INDIRECT() if you want to sum hours.
As in:
=INDIRECT("'Sheet'!R" & MATCH("department_name",A:A,0) & "C" & MONTH(TODAY()), FALSE)
Thank you for all the help in regards to this problem, unfortunatly I could not quite get my head round the suggestions which have been put forward, though I have been able to solve this problem (although it is a messy solution)
=IF($F$95="March",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,2,FALSE),
IF($F$95="April",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,3,FALSE),
IF($F$95="May",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,4,FALSE),
IF($F$95="June",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,5,FALSE),
IF($F$95="July",VLOOKUP(D97,'Planned Hours'!$A$1:K37,6,FALSE),
IF($F$95="August",VLOOKUP(D97,'Planned Hours'!$A$1:K37,7,FALSE),
IF($F$95="September",VLOOKUP(D97,'Planned Hours'!$A$1:K37,8,FALSE),
IF($F$95="October",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,9,FALSE),
IF($F$95="November",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,10,FALSE),
IF($F$95="December",VLOOKUP(D97,'Planned Hours'!$A$1:$K$37,11,FALSE)))))))))))
But it works. Again thanks to all that lent a hand.
--EDIT--
By the way this is not in VBA in the end.

Resources