Sum up matching row and column

icytuvi

New Member
Joined
Feb 2, 2020
Messages
22
Office Version
  1. 2013
Platform
  1. Windows
Hello everyone,

I would like to seek your help with a formula that can help sum up matching row and colum as below (I tried sumifs but did not work).

Thank you very much.

Q.xlsx
ABCDEFGHIJK
2JanFebMarAprJanFebMarApr
3Carrot20202020Apple#VALUE!
4Mango50505050Carrot
5Apple70707070Durian
6Durian30303030Mango
7Mango10101010
Sheet1
Cell Formulas
RangeFormula
H3H3=SUMIFS($B$3:$E$7,$A$3:$A$7,$G3,$B$2:$E$2,H$2)
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Give this a try. I wasn't sure that you actually need a two-way lookup, but this incorporates a match to ensure the correct column is being summed (the INDEX/MATCH), and then the SUMPRODUCT adds the entries that match the row criteria.
MrExcel20200502_b.xlsx
ABCDEFGHIJK
1
2JanFebMarAprJanFebMarApr
3Carrot20202020Apple70707070
4Mango50505050Carrot20202020
5Apple70707070Durian30303030
6Durian30303030Mango60606060
7Mango10101010
Sheet2
Cell Formulas
RangeFormula
H3:K6H3=SUMPRODUCT(INDEX($B$3:$E$7,,MATCH(H$2,$B$2:$E$2,0)),--($G3=$A$3:$A$7))
 
Upvote 0
Give this a try. I wasn't sure that you actually need a two-way lookup, but this incorporates a match to ensure the correct column is being summed (the INDEX/MATCH), and then the SUMPRODUCT adds the entries that match the row criteria.
MrExcel20200502_b.xlsx
ABCDEFGHIJK
1
2JanFebMarAprJanFebMarApr
3Carrot20202020Apple70707070
4Mango50505050Carrot20202020
5Apple70707070Durian30303030
6Durian30303030Mango60606060
7Mango10101010
Sheet2
Cell Formulas
RangeFormula
H3:K6H3=SUMPRODUCT(INDEX($B$3:$E$7,,MATCH(H$2,$B$2:$E$2,0)),--($G3=$A$3:$A$7))

Thank you, Kirk. You have no idea you did me a great help. I really needed the sum with that two-way look up.
 
Upvote 0
You're welcome...glad to help. Incidentally, while this solution ensures that, for example, the January column in the summary table matches the January column in the original data table, it will not find multiple matches...meaning that if there were two or more "Jan" columns in the original data table, it would find only the first. Is that a problem? Put differently, in this hypothetical example, do you need a solution that would find all matching "Jan" columns?
 
Upvote 0
If you have multiple columns with the same name, you'll need a different approach. A solution is shown to the right in O2:S6. I've added a couple of columns with duplicate names to the data table to demonstrate:
MrExcel20200502_b.xlsx
ABCDEFGHIJKLMNOPQRS
1
2JanFebMarJanAprFebJanFebMarAprJanFebMarApr
3Carrot202020502010Apple70707070Apple1001007070
4Mango505050705020Carrot20202020Carrot70302020
5Apple707070307030Durian30303030Durian40703030
6Durian303030103040Mango60606060Mango1501306060
7Mango101010201050
Sheet2
Cell Formulas
RangeFormula
J3:M6J3=SUMPRODUCT(INDEX($B$3:$G$7,,MATCH(J$2,$B$2:$G$2,0)),--($I3=$A$3:$A$7))
P3:S6P3=SUMPRODUCT($B$3:$G$7*(P$2=$B$2:$G$2)*($O3=$A$3:$A$7))
 
Upvote 0
If you have multiple columns with the same name, you'll need a different approach. A solution is shown to the right in O2:S6. I've added a couple of columns with duplicate names to the data table to demonstrate:
MrExcel20200502_b.xlsx
ABCDEFGHIJKLMNOPQRS
1
2JanFebMarJanAprFebJanFebMarAprJanFebMarApr
3Carrot202020502010Apple70707070Apple1001007070
4Mango505050705020Carrot20202020Carrot70302020
5Apple707070307030Durian30303030Durian40703030
6Durian303030103040Mango60606060Mango1501306060
7Mango101010201050
Sheet2
Cell Formulas
RangeFormula
J3:M6J3=SUMPRODUCT(INDEX($B$3:$G$7,,MATCH(J$2,$B$2:$G$2,0)),--($I3=$A$3:$A$7))
P3:S6P3=SUMPRODUCT($B$3:$G$7*(P$2=$B$2:$G$2)*($O3=$A$3:$A$7))
Big thanks for the extra support xD xD xD ~~~ I definitely need it for rearranging my report
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,820
Members
449,049
Latest member
cybersurfer5000

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