SumIF with range across columns and rows

unirSEO

New Member
Joined
Apr 11, 2017
Messages
3
Hello everyone.

I am trying to do a SUMIF where the range consists of multiple columns and rows rather than just a single column.

for example:

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Store 1[/TD]
[TD]Store 2[/TD]
[TD]Store 3[/TD]
[TD]Store 4[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]London[/TD]
[TD]Chicago[/TD]
[TD]Paris[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Paris[/TD]
[TD]NY[/TD]
[TD]Ottawa[/TD]
[TD]18[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Edinburgh[/TD]
[TD]Ottawa[/TD]
[TD]Paris[/TD]
[TD]21[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Edinburgh[/TD]
[TD]Ottawa[/TD]
[TD]Paris[/TD]
[TD]9[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Chicao[/TD]
[TD]London[/TD]
[TD]Paris[/TD]
[TD]46[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]NY[/TD]
[TD]Berlin[/TD]
[TD]LA[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Wellington[/TD]
[TD]Montreal[/TD]
[TD]Paris[/TD]
[TD]44[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Berlin[/TD]
[TD]Berlin[/TD]
[TD]Paris[/TD]
[TD]18[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Ottawa[/TD]
[TD]Paris[/TD]
[TD]Ottawa[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]London[/TD]
[TD]Paris[/TD]
[TD]London[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]Madrid[/TD]
[TD]London[/TD]
[TD]London[/TD]
[TD]6[/TD]
[/TR]
</tbody>[/TABLE]


I want to add together all the Stock for my London stores. Note that the last two rows has London twice.
The sum of that stock is 87 (5+46+12+12+6+6)

I have been messing around with index/match, with CONCATENATE on the stores and using a FIND with a SUMIF, but so far I can't figure out a way of doing it.

But in the end I want a nice table like this-

[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]F[/TD]
[TD]G[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]City[/TD]
[TD]Sum of Stock[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Berlin[/TD]
[TD]36[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Chicago[/TD]
[TD]51[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Edinburgh[/TD]
[TD]30[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]London[/TD]
[TD]87[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]LA[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Madrid[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Montreal[/TD]
[TD]44[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]NY[/TD]
[TD]18[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD]Ottawa[/TD]
[TD]62[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD]Paris[/TD]
[TD]162[/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD]Wellington[/TD]
[TD]44[/TD]
[/TR]
</tbody>[/TABLE]


Any ideas anyone?

Thanks!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Multiple SUMIF is the most straightforward solution:


Book1
ABCDEFG
1Store 1Store 2Store 3Store 4CitySum of Stock
2LondonChicagoParis5Berlin36
3ParisNYOttawa18Chicago51
4EdinburghOttawaParis21Edinburgh30
5EdinburghOttawaParis9London87
6ChicagoLondonParis46LA0
7NYBerlinLA0Madrid6
8WellingtonMontrealParis44Montreal44
9BerlinBerlinParis18NY18
10OttawaParisOttawa7Ottawa62
11LondonParisLondon12Paris180
12MadridLondonLondon6Wellington44
Sheet1
Cell Formulas
RangeFormula
G2=SUMIF($A$2:$A$12,$F2,$D$2:$D$12)+SUMIF($B$2:$B$12,$F2,$D$2:$D$12)+SUMIF($C$2:$C$12,$F2,$D$2:$D$12)


WBD
 
Upvote 0
Thanks WBD.

I was trying to resolve it with a single expression, but that way (which hadn't ocurred to me) is ace!

thanks very much.
 
Upvote 0
[TABLE="class: grid"]
<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]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]Store 1[/TD]
[TD]Store 2[/TD]
[TD]Store 3[/TD]
[TD]Store 4[/TD]
[TD][/TD]
[TD]City[/TD]
[TD]Sum of Stock[/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]London[/TD]
[TD]Chicago[/TD]
[TD]Paris[/TD]
[TD]
5​
[/TD]
[TD][/TD]
[TD]Berlin[/TD]
[TD]
36​
[/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]Paris[/TD]
[TD]NY[/TD]
[TD]Ottawa[/TD]
[TD]
18​
[/TD]
[TD][/TD]
[TD]Chicago[/TD]
[TD]
51​
[/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]Edinburgh[/TD]
[TD]Ottawa[/TD]
[TD]Paris[/TD]
[TD]
21​
[/TD]
[TD][/TD]
[TD]Edinburgh[/TD]
[TD]
30​
[/TD]
[/TR]
[TR]
[TD]
5
[/TD]
[TD]Edinburgh[/TD]
[TD]Ottawa[/TD]
[TD]Paris[/TD]
[TD]
9​
[/TD]
[TD][/TD]
[TD]London[/TD]
[TD]
87​
[/TD]
[/TR]
[TR]
[TD]
6
[/TD]
[TD]Chicago[/TD]
[TD]London[/TD]
[TD]Paris[/TD]
[TD]
46​
[/TD]
[TD][/TD]
[TD]LA[/TD]
[TD]
0​
[/TD]
[/TR]
[TR]
[TD]
7
[/TD]
[TD]NY[/TD]
[TD]Berlin[/TD]
[TD]LA[/TD]
[TD]
0​
[/TD]
[TD][/TD]
[TD]Madrid[/TD]
[TD]
6​
[/TD]
[/TR]
[TR]
[TD]
8
[/TD]
[TD]Wellington[/TD]
[TD]Montreal[/TD]
[TD]Paris[/TD]
[TD]
44​
[/TD]
[TD][/TD]
[TD]Montreal[/TD]
[TD]
44​
[/TD]
[/TR]
[TR]
[TD]
9
[/TD]
[TD]Berlin[/TD]
[TD]Berlin[/TD]
[TD]Paris[/TD]
[TD]
18​
[/TD]
[TD][/TD]
[TD]NY[/TD]
[TD]
18​
[/TD]
[/TR]
[TR]
[TD]
10
[/TD]
[TD]Ottawa[/TD]
[TD]Paris[/TD]
[TD]Ottawa[/TD]
[TD]
7​
[/TD]
[TD][/TD]
[TD]Ottawa[/TD]
[TD]
62​
[/TD]
[/TR]
[TR]
[TD]
11
[/TD]
[TD]London[/TD]
[TD]Paris[/TD]
[TD]London[/TD]
[TD]
12​
[/TD]
[TD][/TD]
[TD]Paris[/TD]
[TD]
180​
[/TD]
[/TR]
[TR]
[TD]
12
[/TD]
[TD]Madrid[/TD]
[TD]London[/TD]
[TD]London[/TD]
[TD]
6​
[/TD]
[TD][/TD]
[TD]Wellington[/TD]
[TD]
44​
[/TD]
[/TR]
</tbody>[/TABLE]


g2=
SUMPRODUCT(($A$2:$C$12=$F2)*($D$2:$D$12))

 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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