SUMIFS with criteria range in horizontal and vertical

exalex

New Member
Joined
Nov 1, 2017
Messages
24
Hello - first time poster! Looking to do a sumifs with the below so that I can sum just the Blue house in 2018 (answer would be 25.00). I want to be able to use this formula to change the color criteria and year criteria. thank you in advance!!

[TABLE="width: 350"]
<tbody>[TR]
[TD="align: right"]1[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD]House[/TD]
[TD]2017*[/TD]
[TD]2018[/TD]
[TD]2019[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD] blue[/TD]
[TD] 1.00 [/TD]
[TD] 25.00 [/TD]
[TD] 24.00 [/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD] yellow[/TD]
[TD] 10.00 [/TD]
[TD] 30.00 [/TD]
[TD] 74.00 [/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD] green[/TD]
[TD] 15.00 [/TD]
[TD] 34.00 [/TD]
[TD] 4.00 [/TD]
[/TR]
[TR]
[TD="align: right"]6[/TD]
[TD] pink[/TD]
[TD] 20.00 [/TD]
[TD] 39.00 [/TD]
[TD] 48.00 [/TD]
[/TR]
</tbody><colgroup><col span="2"><col span="3"></colgroup>[/TABLE]
 

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.
Hi ,

Two points :

1. The SUMIFS family of functions does not work with ranges which are differently oriented , such as one being a column range and the other being a row range. The SUMPRODUCT function will work in this situation.

2. Since you wish to retrieve only one value , using a SUM function is unnecessary ; you can use an INDEX + MATCH to get what you want.

A formula which will do what you want is as follows :

Suppose your data is laid out in the range A1:D5 , where the years are in the range B1:D1 , and the colours are in the range A2:A5.

=INDEX(Data , MATCH(selectedcolour , colours , 0) , MATCH(selectedyear , years , 0))

will give the result you want. Based on the range that I have mentioned :

Data would refer to the range $B$2:$D$5

colours would refer to the range $A$2:$A$5

years would refer to the range $B$1:$D$1

selectedcolour would refer to any cell where you had the particular color for which you wanted the result

selectedyear would refer to any cell where you had the particular color for which you wanted the result
 
Upvote 0
Is there a way to sum rows if the data is interrupted by the criteria i.e

[TABLE="width: 651"]
<colgroup><col span="7"><col><col span="2"></colgroup><tbody>[TR]
[TD="align: right"][TABLE="width: 651"]
<colgroup><col span="6"><col><col><col span="2"></colgroup><tbody>[TR]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]x[/TD]
[TD]10[/TD]
[TD]z[/TD]
[TD]15[/TD]
[TD]y[/TD]
[TD="colspan: 3"]Sum "x" & "y" values in row[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]y[/TD]
[TD]10[/TD]
[TD]x[/TD]
[TD]15[/TD]
[TD]z[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]z[/TD]
[TD]10[/TD]
[TD]y[/TD]
[TD]15[/TD]
[TD]x[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]x[/TD]
[TD]10[/TD]
[TD]z[/TD]
[TD]15[/TD]
[TD]y[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]y[/TD]
[TD]10[/TD]
[TD]x[/TD]
[TD]15[/TD]
[TD]z[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD="align: right"][/TD]
[TD][/TD]
[TD="colspan: 3"][/TD]
[TD="align: right"][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
maybe something like...

Excel 2016 (Windows) 32 bit[TABLE="class: grid, width: 300"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: right"]5[/TD]
[TD]x[/TD]
[TD="align: right"]10[/TD]
[TD]z[/TD]
[TD="align: right"]15[/TD]
[TD]y[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: right"]5[/TD]
[TD]y[/TD]
[TD="align: right"]10[/TD]
[TD]x[/TD]
[TD="align: right"]15[/TD]
[TD]z[/TD]
[TD="align: right"]15[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: right"]5[/TD]
[TD]z[/TD]
[TD="align: right"]10[/TD]
[TD]y[/TD]
[TD="align: right"]15[/TD]
[TD]x[/TD]
[TD="align: right"]25[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: right"]5[/TD]
[TD]x[/TD]
[TD="align: right"]10[/TD]
[TD]z[/TD]
[TD="align: right"]15[/TD]
[TD]y[/TD]
[TD="align: right"]20[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: right"]5[/TD]
[TD]y[/TD]
[TD="align: right"]10[/TD]
[TD]x[/TD]
[TD="align: right"]15[/TD]
[TD]z[/TD]
[TD="align: right"]15[/TD]
[/TR]
</tbody>[/TABLE]
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Worksheet Formulas[TABLE="width: 100%"]
<tbody>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
[TR]
[TH="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]G1[/TH]
[TD="align: left"]=SUM(SUMIF(B1:F1,{"x","y"},A1:E1))[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
it is not always the adjacent cell to the criteria that needs to be part of the sum it could be adjacent plus 1 or 2 from the criteria?
 
Upvote 0
[TABLE="width: 1012"]
<colgroup><col span="2"><col span="4"><col><col><col><col><col><col></colgroup><tbody>[TR]
[TD] [/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[TD]F[/TD]
[TD]G[/TD]
[TD]H[/TD]
[TD]G[/TD]
[TD]I[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]x[/TD]
[TD]10[/TD]
[TD]z[/TD]
[TD]15[/TD]
[TD]07/11/2017[/TD]
[TD]y[/TD]
[TD]Sum of x & y values but ignore Col B[/TD]
[TD]Sum of x & y values but ignore Col A[/TD]
[TD]Both sums need to pick up column F even tho there is other data between the criteria in H.[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]5[/TD]
[TD]7[/TD]
[TD]y[/TD]
[TD]10[/TD]
[TD]x[/TD]
[TD]15[/TD]
[TD] [/TD]
[TD]z[/TD]
[TD] [/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]5[/TD]
[TD]4[/TD]
[TD]z[/TD]
[TD]10[/TD]
[TD]y[/TD]
[TD]15[/TD]
[TD] [/TD]
[TD]x[/TD]
[TD] [/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]5[/TD]
[TD]5[/TD]
[TD]x[/TD]
[TD]10[/TD]
[TD]z[/TD]
[TD]15[/TD]
[TD] [/TD]
[TD]y[/TD]
[TD] [/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]y[/TD]
[TD]10[/TD]
[TD]x[/TD]
[TD]15[/TD]
[TD] [/TD]
[TD]z[/TD]
[TD] [/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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