Determining NETWORKDAYS based on Multiple Criteria - excel

Summary
Sheet 1 - Includes PTO data for every person on a team. This sheet gives me the person's name, the start and end date of their PTO for the year.
Ex:
Sheet1
--------Col1----------------Col2----------------Col3
Row1 John 06/01/2017 06/10/17
Row2 John 06/25/2017 07/05/17
Row3 Jane 06/25/2017 07/05/17
Row2 Robb 06/11/2017 06/15/17
Sheet 2 - Is projecting PTO per Resource Per Month. The Sheet includes a Cell that has the Start Date of the Projection Report and the End Date of the Projection Report. It also includes every team member on the sheet. So think...
Sheet2
A1 = "06/01/2017"
A2 = "06/31/2017"
A5 = "Name of Person"
A6 = "John"
A7 = "Jane"
A8 = "Robb"
B5 = "# of PTO Days for Reporting Period"
On this sheet, Column 2 (B6:B8) I am trying to grab the total network days of each person's PTO based on the date range between A1 and A2. So, those taking PTO that spills into the next month, I wouldn't want to grab TOTAL Network Days for that person, I'd only want to grab Network Days that fall into the range of A1 and A2.
Example - John has two PTO ranges. One whose range is 06/01 - 06/10 (which falls into the range of A1 and A2), but another whose range is 6/25 - 7/05 (so, the 7/1 - 7/5 does NOT fall in the range of A1 and A2). The later, I'd only want to record the NETWORKDAYS within June.
I've tried a few different formulas that enables me to read the name of the employee and only pull network days that fall in the range of A1 and A2, but I'm having difficulty find something that works.
Anyone know how I could have B6:B8 give me the data related to the Resource Name and try to grab all appropriate networkdays for June in Sheet1?
Thanks!

You would need one helper column to extract the networkdays,
Column D is your helper column which finds the networkdays based on the range provided in Sheet2. Use the below formula in column D (sheet1) and drag down,
=IF(AND(B1>=Sheet2!$A$1,C1<=Sheet2!$A$2),NETWORKDAYS(B1,C1),IF(AND(B1<Sheet2!$A$1,C1<=Sheet2!$A$2,C1>=Sheet2!$A$1),NETWORKDAYS(Sheet2!$A$1,C1),IF(AND(B1>=Sheet2!$A$1,B1<=Sheet2!$A$2,C1>Sheet2!$A$2),NETWORKDAYS(B1,Sheet2!$A$2),0)))
Now you will have networkdays for each entry in sheet1, need to use a SUMIF to total it for each person in sheet2. Use the formula in Sheet2 B6 and drag down,
=SUMIF(Sheet1!A:A,A6,Sheet1!D:D)
Hope this helps.
Note:- NETWORKDAYS ignores the weekends.

Related

How to generate invoice numbers with a combination of customer codes without duplicates and sequentially with VBA

Dear All Master,
How to generate invoice numbers with a combination of customer codes without duplicates and sequentially with VBA.
so the position in "C2" is the customer code.
So the "serial" will change continuously in order with the customer code. Does it need invoice numbers stored in their own sheets so that they make it easier for duplicates and sequential to occur? if necessary how?. Please recommend the best solution
in "C4" is the combination invoice number.
JS : COMPANY NAME
12 : MONTH
22 : 2 DIGIT YEAR
XX : CUSTOMER CODE
001 : SERIAL
EXAMPLE
JS-12-22-10-001
JS-12-22-10-002
JS-12-22-11-001
JS-12-22-11-002
Sub generatenumberinvoice()
Sheet1.Range("c3").Value = Sheet1.Range("c3").Value + 1
End Sub
This is not directly help you, but maybe you can have a look and modify it according to your case.
Make a new workbook
Rename Sheet1 into TABLE, Sheet2 into DATA, Sheet3 into FormInput
Type on each sheet exactly like in the picture below. For the time being, ignore the INPUT button which seen in the image of sheet FormInput
In the Name Manager, create a named range CustID which refers to:=OFFSET(TABLE!$A$1,0,0,COUNTA(TABLE!$A:$A),2)
Create another named range : data which refers to: =OFFSET(DATA!$A$1,0,0,COUNTA(DATA!$A:$A),4)
Create another named range : trans which refers to : =OFFSET(FormInput!$A$6,0,0,COUNTA(FormInput!$A:$A)-4,1)
Finally, copy the formula below and paste it to cell B3 of sheet FormInput =IF(COUNTIF(INDEX(data,,3),"*JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"*")<>0,"JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-"&TEXT(AGGREGATE(14,6,RIGHT(INDEX(data,,3),3)/(LEFT(INDEX(data,,3),12)="JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-"),1)+1,"000"),"JS-"&TEXT($B$1,"yy-mm-")&VLOOKUP($B$2,CustID,2,FALSE)&"-001")
Try to type aaa (the name of customer) in cell B2 sheet FormInput. If everything above done correctly, cell B3 will show JS-22-12-10-001. Type bbb then it show JS-22-12-11-001, type ccc then it show JS-22-12-12-001. The last 3 characters always show 001 (which means this is the first invoice number of Dec-22 for whatever id), because there is no data in sheet DATA. Hence it just show 22-12 depends on the date seen in cell B1, and -10 or -11 or -12 depends on the name of the customer seen in cell B2.
Try to change the date to something like 21-nov-22. Cell B3 will show 22-11 and the CustID depends on the name seen in cell B2, and the number always show "001". Play around by changing the date of different month and change the name (aaa or bbb or ccc) so you understand thoroughly how it works.
Now, fill data in sheets DATA exactly like the image below
Back in FormInput, fill the date with Nov-22 month and fill the cust name with aaa, cell B3 will show the next invoice number: JS-22-11-10-006 because the formula read the data that the last number for id 10 in Nov-22 is JS-22-11-10-005, so the formula add 1 to the serial number in cell B3 for id 10 (customer aaa in this case).
Still in November date, type bbb for cust name. It will show JS-22-11-11-001 in cell B3 because there is no data for id 11 of Nov-22. So this is the first invoice number of Nov-22 for id 11 (customer bbb in this case).
Now change the date to December date, then type aaa for cust name. Cell B3 will show the next invoice number for id 10 in Dec-22 is JS-22-12-10-002, because the formula see that the last number in the data for id 10 of Dec-22 is "001".
Still in December date,
type ccc for cust name. Cell B3 will show JS-22-12-12-004.
type bbb for cust name. Cell B3 will show JS-22-12-11-001 which means this is the first invoice number for id 11 in Dec-22.
Play around by filling a different invoice number in sheet DATA then fill the date and the name of the cust in sheet InputForm.
The INPUT button seen in InputForm is a vba code to input the data seen in InputForm into sheet DATA. But this is another case, and if you want to know it, I think you'd better open another question.
Thank you.
Thanks to Mr. Peter_SSs, because I get the formula for cell B3 from him in this link

SumIF three conditions meet return the forth column value

I am having two sheets Sheet1 & Sheet2, Sheet1 having four columns like EMP No, Project Number, Month & Working Days.
In the sheet2 I have same four column but some employee will be worked in two projects for that month, For example: If Emp No, project number & month matches, then 4th column value for that employee should be populated. And I am doing this by referring the cells in both the sheets.
Both sheets having the same order as mentioned in the below.
Column A = Emp No,
Column B = Project Number
Column C = Month
Column D = Working Days
=SUMIFS('Sheet2',$D$2:$D$10000,$C$2:$C$10000,"="&M2,$B$2:$B$10000,"="&C2,$A$2:$A$10000,A2)
I gather your aggregation happens in Sheet2 so the formula should be:
=SUMIFS(Sheet1!D:D,Sheet1!A:A,Sheet2!A1,Sheet1!B:B,Sheet2!B1,Sheet1!C:C,Sheet2!C1)
If your aggregations happens in Sheet1 just go with this one:
=SUMIFS(Sheet2!D:D,Sheet2!A:A,Sheet1!A1,Sheet2!B:B,Sheet1!B1,Sheet2!C:C,Sheet1!C1)
If I've understood correctly, Sheet2 can contain multiple lines for employees per project per month? So, for example, EMP No 1 could be listed for Project 1, in the month of January 5 times, with working days each time equalling 1, and Project 2, int he month of January 2 times, with working days each time equalling 1.
Your Sheet1 worksheet, intends to list all employees, projects and months uniquely in order to total the days worked on each project each month? Based on the example, EMP No 1 would have the following displayed:
What I would suggest, is providing you have the unique list in Sheet1 already set up, enter the following formula into cell D2 (Working Days) and then copy down. I have assumed 100 entries on Sheet2, so you will need to amend the Sheet2! ranges in the formula to suit your data.
=SUMIFS(Sheet2!$D$2:$D$101,Sheet2!$A$2:$A$101,Sheet1!$A2,Sheet2!$B$2:$B$101,Sheet1!$B2,Sheet2!$C$2:$C$101,Sheet1!$C2)

Excel | Formula to find total amount in this situation

Assume that we are currently in the month March. I have a table with all the months and a list of products. Inside each column i have the number sales a product has made on that month, like so:
Notice i have a cell containing "Total until current month". I would require a formula to find out the total amount of sales of a specific product (product A for example) up until March (current month) as you can see with the manually typed 6, 1 in Jan and 5 in Feb.
I would usually do this by finding the sum of cell C4 and D5. But this should be 1 dynamic formula that is updating as we progress onto next month. So as an exammple, in April, it will find the sum of cell C4 - E5 (Jan - March) and update the value.
Is this possible?
Regards
Put a helper row above the month names that has the month numbers 1-12.
Then use SUMIFS():
=SUMIF($C$2:$N$2,"<=" &MONTH(TODAY()),C4:N4)
You could hide that row so it is not visible and not readily accessible.
In row 3 put month numbers. Now if in cell Q4 you have a month number that you want to relate to use:
=SUMIF($C$3:$N$3,"<"&$Q$4,C5:N5)
for sum of A and drag down for other products.
If you want to pick the product you want sum for and have it all in one cell, then assuming that in cell R4 you have your product name (e.g. "B") write
=SUM((C3:N3<Q4)*C5:N6*(B5:B6=R4))
and press ctrl+shift+enter.
The simplest solution is to leave E4 through N4 empty. Only put a value in E4 once March is complete and you have a value for March. This will allow a formula like:
=SUM(C4:N4)
for Product A

Countif formula with multiple criteria

In my workbook, I have a 4 spreadsheets - Data, Amy, Betty, Connie. Data has the following columns:
Column A Column B Column C Column D
Row 3 Employee Total tasks last 30 days. Total tasks last 7 days. Date/Time Last task Assigned
Row 4 Amy
Row 5 Betty
Row 6 Connie
In A1 - worker with oldest task Date/Time Assigned. Cell B1 contains the answer to cell A1 by providing the employees name.
I enter the data in the individual workers spreadsheets (Amy, Betty, Connie) and my Data worksheet provides the summary. On my data worksheet, I have formulas that count the number of tasks within the last 7 days and last 30 days by using the date/time assigned column (Column E)in the individual worksheets. Currently, if someone is out of the office, on their individual worksheet, I enter OUT in the task column (Column B) and the date/time that they will return in the date/time assigned column (Column E)so it will skip them for B1 on my Data worksheet. I need a formula that would not count the date/time assigned if they were OUT as a task, when calculating in columns B and C in the data worksheet.
Here is the formula that I have currently for Column B (total tasks last 30 days)
{=COUNTIF(INDIRECT("'"&A4&"'!"&"E1:E1000"),">="&(NOW()-30))}
The formula that I have for cell B1 is:
{=INDEX(A4:A14,MATCH(MIN(E4:E14),E4:E14,0))}
Any help would greatly be appreciated.
I figured it out:
=COUNTIFS(Amy!E2:E1000,">="&(NOW()-30),Amy!A2:A1000,"<>out")
Like suggested in the comments, the COUNTIFS formula is what you want to use. Information about its usage can be found here.
Adding the condition for excluding the "OUT" values would make the formula look like this:
=COUNTIFS(INDIRECT(""&A4&"!"&"E1:E1000"),">="&(NOW()-30),INDIRECT(""&A4&"!"&"B1:B1000"),"<>OUT")

Excel Countif using month and letter as Criteria's

I have a list of sales data that includes the date of the sale and also a sales type code. I'm trying to use COUNTIFS to count how many sales of a specific type there were during each month .
So for example:
Date. Sales Type Code
10/01/2014. S
12/01/2014. S
15/01/2014. O
18/01/2014. S
02/02/2014. O
08/02/2014. S
Would give me the following results:
Code S
January - 3
February - 1
Code O
January - 1
February - 1
I have the formula
COUNTIFS('SALES LEDGER'!A:A,F2,'SALES LEDGER'!C:C,"<"&EOMONTH('MONTH Sales by Sales Type'!$C$1,0)+1)
Where A:A is the list of Sales Type Codes, F2 is the code I want to count, C:C is the list of dates and C1 is the first of the month I want to count (ie. 01/01/2014).
This works fine for January, giving me the expected result. But when I change C1 to 01/02/2014, it counts January and February together, rather than just February.
If anyone has any suggestions it would be appreciated!
Thanks
Your COUNTIFS formula specifies an end date but no start date, if you want to count for a specific month and year (based on C1) you need another criterion to specify the start date using C1, i.e.
=COUNTIFS('SALES LEDGER'!A:A,F2,'SALES LEDGER'!C:C,"<"&EOMONTH('MONTH Sales by Sales Type'!$C$1,0)+1,'SALES LEDGER'!C:C,">="&'MONTH Sales by Sales Type'!$C$1)
You could use this one (if your range with dates doesn't contain empty cells):
=SUMPRODUCT((MONTH(A2:A100)=1)*(B2:B100="S"))
or (if your range could contain empty cells)
=SUMPRODUCT((TEXT(A2:A100,"mmm")="Jan")*(B2:B100="S"))
If you need to add also year condition, just add *(YEAR(A2:A100)=2014) in any formula:
=SUMPRODUCT((TEXT(A2:A100,"mmm")="Jan")*(YEAR(A2:A100)=2014)*(B2:B100="S"))
Assuming:
it is amenable to use helper columns
Dates in col A
Sale Type Codes in col B
Results placed from A9:C11
Screenshot:
Add a helper col C to extract Month from date. Add this formula in C2 and drag down:
=TEXT(A2,"Mmm")
Add this formula in B10 and drag down and across:
=COUNTIFS($B$1:$B$7,B$9,$C$1:$C$7,$A10)
with the code below you can retrieve the month each date is in:
dim objDate as Date
dim i as integer
dim intMonth as integer
for i = 2 to 'number of row
objDate = CDate(cells(i, 1))
intMonth = Month(objDate)
next i
After figuring out the month with a simple loop you can count the number of sales in each month.

Resources