SumProduct Multiple Columns

dcamos

Board Regular
Joined
May 21, 2008
Messages
225
I have a number in column B, either 68, 623 or 711 and I want to sum columns D through O (the entire row) if column B matches that number above.

I tried sumproduct(--(B2:B20=A1),D2:O20) but that didn't work and I am not sure where to go from there.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I have a number in column B, either 68, 623 or 711 and I want to sum columns D through O (the entire row) if column B matches that number above.

I tried sumproduct(--(B2:B20=A1),D2:O20) but that didn't work and I am not sure where to go from there.

Not clear whether you want to match a range against 68, 623, and 711 separately or together...

Separately...

Control+shift+enter, not just enter:

=SUM(IF($B$2:$B$20=A1,$D2:$O$20))

Together...

Control+shift+enter, not just enter:

=SUM(IF(ISNUMBER(MATCH($B$2:$B$20,A1:A3,0)),$D$2:$D$20))

where A1:A3 houses 68, 623, and 711.
 
Upvote 0
If you can post some data that will help.

I tried sumproduct(--(B2:B20=A1),D2:O20) but that didn't work and I am not sure where to go from there.

try =sumproduct(--(B2:B20=A1),--(D2:O20))

But the above second part normally needs to look like this (D2:02=??))
 
Upvote 0
Joneye, I regularly use sumproduct the way it was written, the second part is the sum range, it works for me all the time that way.
 
Upvote 0
Ok, but if you can post a group of data i can look it,
 
Upvote 0
I didn't think to try sum(if after sumproduct wouldn't do what I wanted.

Thanks,

SUMPRODUCT(--(A2:A10="X"),--(B2:B10="Y"))

and

SUMPRODUCT(A2:B10,F2:G10)

are OK, but when mixing vectors with matrices are needed,
SumProduct's native syntax cannot be observed. In such cases,
it is better to invoke more flexible SUM/IF formulas.
 
Upvote 0
I think Aladin, has given you a robust solution....

The reason that this doesn't work....

=SUMPRODUCT(--(B2:B20=A1),D2:O20)

.....is because all the ranges need to be the same size. Excel help says this

"The array arguments must have the same dimensions. If they do not, SUMPRODUCT returns the #VALUE! error value"

There is a workaround using SUMPRODUCT, if you multiply the two ranges then SUMPRODUCT is, in fact, dealing with only one array, e.g.

=SUMPRODUCT((B2:B20=A1)*D2:O20)

but note that this will give you an error if there is any text in the sum range D2:O20
 
Upvote 0

Forum statistics

Threads
1,224,590
Messages
6,179,753
Members
452,940
Latest member
rootytrip

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