Match name and return sum between date range

ExceLoki

Well-known Member
Joined
Dec 13, 2021
Messages
538
Office Version
  1. 365
Platform
  1. Windows
i'm trying to return a sum value from a range of data by matching a name and between a set of dates. i've got the dates in the results sheet in two columns.
i'm stuck, any help is appreciated. and for some reason xl2bb keeps freezing my excel so i had to just copy the sheets

here is what i was trying to use in sheet7 column I:
Excel Formula:
=SUMIFS(Sheet6!$C$5:$Z$8,Sheet6!2:2,">="&A2,Sheet6!2:2,"<="&B2,Sheet6!A:A,D2)

here is a sample of data, coulmn A is a lookup for the name matching the email. the email and the rest is from a pivot table:
Sheet6
ABCDEFGHIJKLMNOPQRSTUVWXYZ
NameRow Labels04/01/202204/02/202204/04/202204/05/202204/06/202204/07/202204/08/202204/11/202204/12/202204/13/202204/14/202204/15/202204/18/202204/19/202204/20/202204/21/202204/22/202204/23/202204/25/202204/26/202204/27/202204/28/202204/29/202204/30/2022
Bob SmithBob.Smith@company.com
11​
9​
9​
8​
1​
9​
9​
6​
5​
6​
7​
3​
7​
8​
5​
11​
10​
1​
Jane DoeJane.Doe@company.com
5​
9​
5​
8​
5​
6​
4​
8​
8​
1​
2​
4​
5​
8​
1​
1​
1​
2​
1​
2​
3​
5​
9​
Bob DoeBob.Doe@company.com
1​
2​
1​
1​
7​
8​
1​
2​
1​
4​
1​
7​
1​
2​
2​
4​
9​
3​
Jane SmithJane.Smith@company.com
2​
1​
3​
7​
9​
6​
4​
11​
1​
1​
3​
1​
4​
8​
9​
7​
9​
4​

here is a sample of the result:
Sheet7
ABCDEFGHI
Start DateEnd DateReport RanFull Namefield 1field 2field 3field 4Cases Worked
4/1/20224/7/20224/9/2022Bob Smith37
4/1/20224/7/20224/9/2022Jane Doe38
4/1/20224/7/20224/9/2022Bob Doe3
4/1/20224/7/20224/9/2022Jane Smith13
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
You will need to use sumproduct for that.
Excel Formula:
=sumproduct((Sheet6!2:2>=A2)*(Sheet6!2:2<=B2)*(Sheet6!A:A=D2)*(Sheet6!$C$5:$Z$8))
although you would be better off not using entire column/row references.
 
Upvote 0
Or maybe like this . . .
Code:
=SUMIFS(OFFSET(Sheet6!$C$2,MATCH(D2,Sheet6!A3:A6,0),0,1,24),Sheet6!C2:Z2,">="&A2,Sheet6!C2:Z2,"<="&B2)

Edited to add - I've missed out some $ symbols here, you'll need to sprinkle a few of those in here :)
 
Upvote 0
ok, now xl2bb is working for me. in the last replies the formulas returned #NA

case tracker-WIP.xlsx
ABCDEFGHI
1Start DateEnd DateReport RanFull Namefield 1field 2field 3field 4Cases Worked
24/1/20224/7/20224/9/2022Bob Smith37
34/1/20224/7/20224/9/2022Jane Doe38
44/1/20224/7/20224/9/2022Bob Doe3
54/1/20224/7/20224/9/2022Jane Smith13
Sheet7
Cell Formulas
RangeFormula
B2:B5B2=A2+6
C2:C5C2=B2+2

-----------------
case tracker-WIP.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1NameRow Labels04/01/202204/02/202204/04/202204/05/202204/06/202204/07/202204/08/202204/11/202204/12/202204/13/202204/14/202204/15/202204/18/202204/19/202204/20/202204/21/202204/22/202204/23/202204/25/202204/26/202204/27/202204/28/202204/29/202204/30/2022
2Bob SmithBob.Smith@company.com119981996567378511101
3Jane DoeJane.Doe@company.com59585648812458111212359
4Bob DoeBob.Doe@company.com121178121417122493
5Jane SmithJane.Smith@company.com2137964111131489794
Sheet6
 
Upvote 0
With that layout, this worked for me
Excel Formula:
=SUMPRODUCT((Sheet6!$C$1:$Z$1>=A2)*(Sheet6!$C$1:$Z$1<=B2)*(Sheet6!$A$2:$A$100=D2)*(Sheet6!$C$2:$Z$100))
 
Upvote 0
Solution
Well I'm not getting #N/A errors.
Here's a slightly different version, with the $ symbols added in.
=SUMIFS(OFFSET(Sheet6!$C$2,MATCH(D2,Sheet6!A$3:A$6,0),0,1,24),Sheet6!C$1:Z$1,">="&A2,Sheet6!C$1:Z$1,"<="&B2)
Is this exactly what you have in I2 ?

Edit - I originally had the dates on Sheet6 in Row 2, I've changed that now to Row 1.
 
Upvote 0
now both are returning 0 values. the current values in column I on this example are manually entered.
@Gerald - i had to edit yours to look at the range of names
----------------
case tracker-WIP.xlsx
ABCDEFGHIJKL
1Start DateEnd DateReport RanFull Namefield 1field 2field 3field 4Cases WorkedFLUFFGerald-editGerald
24/1/20224/7/20224/9/2022Bob Smith3700#N/A
34/1/20224/7/20224/9/2022Jane Doe38000
44/1/20224/7/20224/9/2022Bob Doe3000
54/1/20224/7/20224/9/2022Jane Smith13000
64/8/20224/14/20224/16/2022Bob Smith1900#N/A
74/8/20224/14/20224/16/2022Jane Doe21000
84/8/20224/14/20224/16/2022Bob Doe17000
94/8/20224/14/20224/16/2022Jane Smith30000
104/15/20224/21/20224/23/2022Bob Smith2400#N/A
114/15/20224/21/20224/23/2022Jane Doe21000
124/15/20224/21/20224/23/2022Bob Doe9000
134/15/20224/21/20224/23/2022Jane Smith5000
144/22/20224/28/20224/30/2022Bob Smith3400#N/A
154/22/20224/28/20224/30/2022Jane Doe10000
164/22/20224/28/20224/30/2022Bob Doe16000
174/22/20224/28/20224/30/2022Jane Smith29000
184/29/20225/5/20225/7/2022Bob Smith1100#N/A
194/29/20225/5/20225/7/2022Jane Doe14000
204/29/20225/5/20225/7/2022Bob Doe12000
214/29/20225/5/20225/7/2022Jane Smith13000
Sheet7
Cell Formulas
RangeFormula
B2:B21B2=A2+6
C2:C21C2=B2+2
J2:J21J2=SUMPRODUCT((Sheet6!$C$1:$Z$1>=A2)*(Sheet6!$C$1:$Z$1<=B2)*(Sheet6!$A$2:$A$100=D2)*(Sheet6!$C$2:$Z$100))
K2:K21K2=SUMIFS(OFFSET(Sheet6!$C$2,MATCH(D2,Sheet6!A$2:A$6,0),0,1,24),Sheet6!C$2:Z$2,">="&A2,Sheet6!C$2:Z$2,"<="&B2)
L2:L21L2=SUMIFS(OFFSET(Sheet6!$C$2,MATCH(D2,Sheet6!A$3:A$6,0),0,1,24),Sheet6!C$2:Z$2,">="&A2,Sheet6!C$2:Z$2,"<="&B2)
A6,A10,A14,A18A6=B5+1
A7,A11,A15,A19A7=A6
A8,A12,A16,A20A8=A6
A9,A13,A17,A21A9=A6
 
Upvote 0
Check that all the dates are real dates & not text.
 
Upvote 0
does it matter that sheet 6 is a pivot table? maybe that's why it's not working correctly?
 
Upvote 0
I don't think a pivot table should make any difference.

Did you do what Fluff suggested in post #8 ?
That could definitely make a difference, if some values are not really dates but just text strings.
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top