Sum multiple columns & rows

AliAlhashim

New Member
Joined
May 13, 2018
Messages
3
Dears,

I have the following table:

[TABLE="width: 377"]
<tbody>[TR]
[TD]Name/Month[/TD]
[TD="align: right"]1[/TD]
[TD="align: right"]2[/TD]
[TD="align: right"]5[/TD]
[TD="align: right"]4[/TD]
[/TR]
[TR]
[TD]Nissan[/TD]
[TD="align: right"]100[/TD]
[TD="align: right"]140[/TD]
[TD="align: right"]120[/TD]
[TD="align: right"]30[/TD]
[/TR]
[TR]
[TD]Honda[/TD]
[TD="align: right"]45[/TD]
[TD="align: right"]456[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]841[/TD]
[/TR]
[TR]
[TD]Toyota[/TD]
[TD="align: right"]4[/TD]
[TD="align: right"]7[/TD]
[TD="align: right"]46[/TD]
[TD="align: right"]26[/TD]
[/TR]
</tbody><colgroup><col><col span="4"></colgroup>[/TABLE]


What I'm trying to do is to sum numbers in this table based on some criteria for rows and columns.

For example, I want to sum Nissan for the months of 1 & 5.

What I have reached so far is this formula: =SUMPRODUCT((A2:A4="Nissan")*(B1:E1=1)*B2:E4)

However, I'm unable to add multiple months to this formula.

Any help?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the MrExcel board!

See if this helps.

Excel Workbook
ABCDEFGH
1Name/Month1254NameNissan
2Nissan10014012030Months1,5
3Honda454564841Sum220
4Toyota474626
SUM
 
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]
[TD]
H
[/TD]
[TD]
I
[/TD]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]Name/Month[/TD]
[TD]
1​
[/TD]
[TD]
2​
[/TD]
[TD]
5​
[/TD]
[TD]
4​
[/TD]
[TD][/TD]
[TD][/TD]
[TD]month[/TD]
[TD]sum[/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]Nissan[/TD]
[TD]
100​
[/TD]
[TD]
140​
[/TD]
[TD]
120​
[/TD]
[TD]
30​
[/TD]
[TD][/TD]
[TD]Nissan[/TD]
[TD]
1​
[/TD]
[TD]
220​
[/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]Honda[/TD]
[TD]
45​
[/TD]
[TD]
456​
[/TD]
[TD]
4​
[/TD]
[TD]
841​
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
5​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]Toyota[/TD]
[TD]
4​
[/TD]
[TD]
7​
[/TD]
[TD]
46​
[/TD]
[TD]
26​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I2=SUMPRODUCT((A2:A4=G2)*(ISNUMBER(MATCH(B1:E1,H2:H3,0))),B2:E4)
 
Upvote 0
Dear Peter & MARZIOTULLIO

Thanks a lot for your quick reply, both formula works as a charm.

Do you think it's possible to use this formula to search for partial text?

For example, instead of Nissan, I want to search for "Niss"?

Best Regards,
 
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]
[TD]
H
[/TD]
[TD]
I
[/TD]
[/TR]
[TR]
[TD]
1
[/TD]
[TD]Name/Month[/TD]
[TD]
1​
[/TD]
[TD]
2​
[/TD]
[TD]
5​
[/TD]
[TD]
4​
[/TD]
[TD][/TD]
[TD][/TD]
[TD]month[/TD]
[TD]sum[/TD]
[/TR]
[TR]
[TD]
2
[/TD]
[TD]Nissan[/TD]
[TD]
100​
[/TD]
[TD]
140​
[/TD]
[TD]
120​
[/TD]
[TD]
30​
[/TD]
[TD][/TD]
[TD]Niss[/TD]
[TD]
1​
[/TD]
[TD]
220​
[/TD]
[/TR]
[TR]
[TD]
3
[/TD]
[TD]Honda[/TD]
[TD]
45​
[/TD]
[TD]
456​
[/TD]
[TD]
4​
[/TD]
[TD]
841​
[/TD]
[TD][/TD]
[TD][/TD]
[TD]
5​
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]
4
[/TD]
[TD]Toyota[/TD]
[TD]
4​
[/TD]
[TD]
7​
[/TD]
[TD]
46​
[/TD]
[TD]
26​
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


I2=SUMPRODUCT((ISNUMBER(SEARCH(G2&"*",A2:A4)))*(ISNUMBER(MATCH(B1:E1,H2:H3,0))),B2:E4)
 
Upvote 0
The change for my method & layout would be
Code:
=SUMPRODUCT(--ISNUMBER((FIND(","&B1:E1&",",","&H2&","))*(SEARCH(H1,A2:A4))),B2:E4)
 
Upvote 0

Forum statistics

Threads
1,224,826
Messages
6,181,192
Members
453,021
Latest member
pingpong7117

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