Excel - Refer to column/range with Networkdays - excel

=COUNTIFS(NETWORKDAYS(C:C, TODAY(), 1),">=" & 5)
I am trying to use something like the above to count any values in Column C (Date column of my dataset) where the working days from then to todays date is greater than 5. Can this be done without creating a working days column?

It's actually not so obvious but NETWORKDAYS does not work with ranges. Arrays however are completely fine. See this post on SuperUser too.
So in your case you could simply use:
=SUMPRODUCT(--(NETWORKDAYS(C:C+0,TODAY())>=5))
Obviously it's better not to reference the whole of column C. Depending if one has Excel O365, you could also just use =SUM instead of =SUMPRODUCT.

Related

Excel VLOOKUP with multiple possible options in table array

I have two lists, the first is a set of users. The second list contains different encounter dates for these users.
I need to identify the date that is within 10 days of the "Renew Date" [Column C], but not before. With Member 1 this would be row 3 1/8/2017. With Member 2 this would be row 6, 1/21/2017.
Now using a VLOOKUP which the user before me who managed this spreadsheet obviously isn't viable as it's simply going to pickup the first date that has a matching Member ID. Is there a way to do this in Excel at all?
I have included a link to a sample file and a screenshoit of the sample data.
https://drive.google.com/file/d/0B5kjsJZFrUgFcUFTNFBzQzN4cm8/view?usp=sharing
To avoid the slowness and complexities of array formulas, you can try with SUMIFS but the problem is that if you have more than one match, it will add them, not return the first match. The sum will look like an aberration. Will work however if you are guaranateed that you have only one match in the data.
An alternative is also to use AVERAGEIFS, which, in case of multiple matches, will give you their average and it will look like a valid date and a good result. Enter this formula in D2 and fill down the column:
D2:
=AVERAGEIFS(G:G,F:F,A2,G:G,">="&C2,G:G,"<="&C2+10)
and don't forget to format column D as Date.
Try this
=SUMPRODUCT($G$2:$G$7,--($F$2:$F$7=A2),--($G$2:$G$7<=C2+10),--($G$2:$G$7>C2))
Format the result as date. See screenshot (my system uses DMY order)
Don't use whole column references with this formula. It will slow down the workbook.

Excel count if date in one column is within certain range from date in another column

I've searched all over the Internet for an answer on this and although I've found similar questions, none of them have helped me solve my own little issue:
Let's say I have a two column list, with start dates and end dates - 10 rows so A1:B10. Start dates are in Column A, end dates are in Column B. I want to write a form of CountIf-function (or sumproduct/sumif, whatever gives the required result) that counts only the rows where the start date is more than 365 days earlier than the end date.
The simple way to do this is obviously to make a column C that simply counts the difference by subtracting each start date from each end date, but I want a function that does all the work as I'm going to apply this to a much bigger data set.
Ideally I want the solution to be able to be written as a criteria in a countif, or sumproduct-function as I am working with multiple criterias.
Many many thanks for your help!
Use the following array formula (enter with (Ctrl+Shift+Enter):
=SUM(IF(B1:B10-A1:A10>365,1,0))
An alternate which does not require array entry:
=SUMPRODUCT(--(B1:B10-A1:A10>365))

SUMIF doesn't work with nested MONTH or LEFT function

I'm started with the following:
=SUMIF(MONTH('Inventory'!K:K),B5,'Inventory'!M:M)
where MONTH('Inventory'!K:K) is supposed to return the month number (Jan=1, Feb=2, etc.) from a mm/dd/yyyy date column, B5 holds the month number I want to sum by, and 'Inventory'!M:M is an amount column.
In place of MONTH('Inventory'!K:K) I also tried LEFT('Inventory'!K:K, 1) with no luck.
I though possibly that the MONTH expression is returning a value where Excel is looking for a Range, but I wasn't able to find a workaround. Tried the following, which also didn't work:
=SUMIF('Inventory'!K:K,MONTH('Inventory'!K:K)=B5,'Inventory'!M:M)
While a pivot could work, I wanted the user to be able to just add to the Inventory tab without worrying about refreshing.
Create start and end dates from the numerical month in B5 rather than trying to convert the dates in column K to numerical month integers.
=SUMIFS('Inventory'!M:M, 'Inventory'!K:K, ">="&date(2017, B5, 1), 'Inventory'!K:K, "<"&date(2017, B5+1, 1))
Note SUMIFS, not SUMIF; they have a slightly different syntax.
Alternately, use SUMPRODUCT.
=SUMPRODUCT((MONTH('Inventory'!K:K)=B5)*('Inventory'!M:M))
You should trim down the full column references with SUMPRODUCT or be prepared to suffer calculation lag.
=SUMPRODUCT((MONTH('Inventory'!K2:index('Inventory'!K:K, match(1e99, 'Inventory'!K:K)))=B5)*('Inventory'!M2:index('Inventory'!M:M, match(1e99, 'Inventory'!K:K))))
Depends what you need, but here are two options that don't restrict you to one year's worth of months:
1) Create a helper column next to 'Inventory'!K:K to extract the month, then write your SUMIF using that column as the range.
2) Use SUMPRODUCT like so:
=SUMPRODUCT((MONTH('Inventory'!K:K)=B5)*'Inventory'!M:M)

Excel Formula to Count Values between Dates

I am looking for a way to count how many companies are in Column C on the specific dates of column A. Can one formula be applied to the count between all of dates?
I have tried looking up and using =CountBlanks and I do not want to have to manually select the cell ranges between the dates.
Ultimately I am also trying to put this data into a table so I can see on Feb 16 = 3 Companies, Feb 19 = 5. I can not use a VBA script as some users have macros blocked.
Please look at image for example
Example Image
Try this formula:
=COUNTA(INDEX($C$2:$C$21,MATCH($E2,$A$2:$A$21,0)):INDEX($C$2:$C$21,MIN(IFERROR(MATCH(TRUE,INDEX($A$2:$A$21>$E2,0),0),9999999),MATCH(TRUE,INDEX($C$2:$C$21="",0),0))-1))
Change the 21s in the formula to at least the extent of your data +1, It can be more, Full column references will not work due to the Word "Date" in the first row.
DATEDIF( start_date, end_date, interval )
you didnt even bother to google this, right?
edit: there should be enough common place stuff like isblank to accommodate the lack of values. If youre trying to find the values between A & C then you can easily adjust your formula accordingly.

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