Sumifs across rows and columns

CarolynS

Board Regular
Joined
Oct 27, 2015
Messages
56
I have a data set with unique id numbers down the left hand colum and dates (week commencing) across the top. For each unique ID I want to sum the data if it falls under a specific month. So for example I want to say for the unique id number, if the date contains the month of october then sum this data. I would normally use a sumifs for this but I'm not sure how to do this when the criteria is a column header? Not sure if it needs to be combined with Index match but not sure how?

Thanks

Example table below

10 Oct 1617 Oct 1624 Oct 1631 Oct 167 Nov 16
Unique ID
07054269
07136726
07268141
07392883

<tbody>
</tbody>
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I believe this does what you want:


Excel 2016 (Windows) 32 bit
KLMNOPQ
310-Oct-1617-Oct-1624-Oct-1631-Oct-1607-Nov-16
4Unique ID
57054269
67136726
77268141
87392883
9
10ID7017
11Month10
Sheet4
Cell Formulas
RangeFormula
M10=SUMPRODUCT((MONTH(M3:Q3)=L11)*(L5:L8=L10),M5:Q8)
 
Upvote 0
A
B
C
D
E
F
G
1
10-Oct-16​
17-Oct-16​
24-Oct-16​
31-Oct-16​
7-Nov-16​
2
Unique ID
3
70​
5​
4​
2​
6​
9​
17​
4
71​
3​
6​
7​
2​
6​
18​
5
72​
6​
8​
1​
4​
1​
19​
6
73​
9​
2​
8​
8​
3​
27​

<tbody>
</tbody>

G3=SUMPRODUCT(($A$3:$A$6=A3)*(MONTH($B$1:$F$1)=10)*($B$3:$F$6)) copy down
 
Upvote 0
G3=SUMPRODUCT(($A$3:$A$6=A3)*(MONTH($B$1:$F$1)=10)*($B$3:$F$6))

I think the section in red should be $B3:$F6, otherwise it will not increment as you drag down.
 
Last edited:
Upvote 0
I have amended the formula slightly to fit my data set and it is working :) I am currently using:

=SUMPRODUCT((MONTH('L&D Consultant'!E2:BA2)=MONTH(F1))*('L&D Consultant'!D10:D16=D2),'L&D Consultant'!E10:BA16)

L&D Consultant is the name of the tab my data is sat in. The formula is sat in a dfferent tab (called 'Calcs') and is looking at cell F1 to obtain the month (i've added in month() here as this cell contains a full date) and cell D2 as this contains the unique ID i want to look up.

My data is split out across mutliple sheets depending on the role type of employees. So for example, there might be one tab called 'L&D Consultant' and one called 'Manual Labourer' etc. Ideally I'd like the formula to automatically pick up the role type (the role type is specified in the calcs tab next to the unique id) and use this to determine the name of the sheet it looks in. Is there a way to do this other than using a nested if?

Also the range area for each role type is different, i.e.the data range on the L&D Consultant sheet is E10:BA16 but in the Manual Labourer sheet it might be E10:BA100. Is there a way to get the formula to take this in to account? I'm looking to remove as much manual intervention as possible. The workbook will be updated regularly and the range sizes will change. Each sheet may also have more than one set of data within it for each role within the role type i.e. L&D Consultant may contain 2 or 3 roles, each role has a set of data within the L&D Consultant sheet but each set if data is seperated by several blank rows. So, depending on the role, the range will need to be different in the formula

Does that make any sense?
 
Upvote 0
I have now used indirect to use the role type in column B to determine the sheet name where required and have set the range to go down to row 200 as none of my data sets will exceed 200 rows. All seems to be working - just need to test it

=SUMPRODUCT((MONTH(INDIRECT("'"&B2&"'!E2:BA2"))=MONTH(F1))*(INDIRECT("'"&B2&"'!D10:D200")=D2),INDIRECT("'"&B2&"'!E10:BA200"))
 
Upvote 0

Forum statistics

Threads
1,215,581
Messages
6,125,656
Members
449,246
Latest member
jbbtz28

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