SOLVED

Is this possible with SumProduct?

Copper Contributor

Hi,

 

I have a worksheet that looks something like this:

 

 

xABCDEF
1# of unitsTomJerryRachelSarahSam

2

1

AppleApple

Pear

Orange 
33BananaPearOrangeGrapeApple
44OrangeApple   
51Pear    
6      
7Apple     

 

The data is actually more complex and is simplified here, so it cannot be grouped more efficiently.  I am trying to figure out a formula to determine how many apples there are in the entire array.  In this example the answer is 9.

 

Currently, I am using this formula in cell B7: =SUM(SUMPRODUCT(--($A$7=$B$2:$B$5),$A$2:$A$5),SUMPRODUCT(--($A$7=$C$2:$C$5),$A$2:$A$5),SUMPRODUCT(--($A$7=$D$2:$D$5),$A$2:$A$5),SUMPRODUCT(--($A$7=$E$2:$E$5),$A$2:$A$5),SUMPRODUCT(--($A$7=$F$2:$F$5),$A$2:$A$5))

 

It works, but there are many more columns in my data set so as it gets larger, it gets more cumbersome.  I was wondering if there was a more efficient formula that I should be using.

 

Thank you!

3 Replies
best response confirmed by TM20204 (Copper Contributor)
Solution

@TM20204

 

Hi,

 

=SUMPRODUCT(A2:A5*(B2:F5=A7))

 

Cheers.

Works perfectly! Thank you! @Jos_Woolley 

No worries! Glad to help @TM20204 !

1 best response

Accepted Solutions
best response confirmed by TM20204 (Copper Contributor)
Solution

@TM20204

 

Hi,

 

=SUMPRODUCT(A2:A5*(B2:F5=A7))

 

Cheers.

View solution in original post