SUMIF with Row AND Column Criteria

Slazar

New Member
Joined
Aug 28, 2015
Messages
17
Welcome everyone! This is my first post here. I hope to become an Excel master in due time.
A B C D
1 Oranges Apples Banana

2 Red 3 5 7

3
Blue 5 3 6

4
Red 2 1 1

5 Blue 5 5 5

Can somebody explain to me how to sum the numbers as to get all types of fruits in only one colored basket?
I need a draggable formula.

I'm having a lot of trouble trying to get to this despite looking in the forums.

A B C D
1 Oranges Apples Banana

2 Red [Formula here]

3
Blue
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try this:

=SUMPRODUCT(($B$2:$D$5)*--($A$2:$A$5=$A7)*--($B$1:$D$1=B$6))

Change the following ranges to suit your data:
B2:D5 is the sum range, A2:A5 is the colors, A7 is the color in your summary table, B1:D1 is the fruit, B6 is the fruit in your summary table.

Enter in B2 in your summary table, copy across and down.
 
Upvote 0
Try this:

=SUMPRODUCT(($B$2:$D$5)*--($A$2:$A$5=$A7)*--($B$1:$D$1=B$6))

Change the following ranges to suit your data:
B2:D5 is the sum range, A2:A5 is the colors, A7 is the color in your summary table, B1:D1 is the fruit, B6 is the fruit in your summary table.

Enter in B2 in your summary table, copy across and down.

This *-- is not illegal, but it does not make sense. You should use either only * or replace your *-- usage with ,--, that is, comma followed by double minus...
 
Upvote 0
@Slazar

Row\Col
A​
B​
C​
D​
E​
F​
G​
H​
I​
J​
1​
OrangesApplesBananaOrangesApplesBanana
2​
Red
3​
5​
7​
Red
5​
6​
8​
3​
Blue
5​
3​
6​
Blue
10​
8​
11​
4​
Red
2​
1​
1​
5​
Blue
5​
5​
5​

H2, copied across and down:

=SUMIFS(INDEX($B$2:$D$5,0,MATCH(H$1,$B$1:$D$1,0)),$A$2:$A$5,$G2)

which is fast.

More generic and dynamic...

H2, copied across and down:

=SUMIFS(INDEX($B:$D,0,MATCH(H$1,INDEX($B:$D,1,0),0)),$A:$A,$G2)
 
Upvote 0
Thank you! It worked!

Quick question. How do you insert a snapshot of the Excel sheet or perhaps make a table like Aladin's?
 
Upvote 0
This *-- is not illegal, but it does not make sense. You should use either only * or replace your *-- usage with ,--, that is, comma followed by double minus...

When I do this, ',--', the formula returns #VALUE. Otherwise, the formula works fine when I use '*--'.
 
Upvote 0
When I do this, ',--', the formula returns #VALUE. Otherwise, the formula works fine when I use '*--'.

You have to use the * operator if you want to process a matrix range (B2:D5 is such) in a SumProduct formula, that is:

=SUMPRODUCT(($B$2:$D$5)*($A$2:$A$5=$A7)*($B$1:$D$1=B$6))

But, if a SUMIFS formula is appropriate, one would go for that. If a matrix range must be processed, better switch to an more appropriate array-processing formula:

=SUM(IF($A$2:$A$5=$A7,IF($B$1:$D$1=B$6,$B$2:$D$5)))

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,215,833
Messages
6,127,156
Members
449,367
Latest member
w88mp

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