Calculate totals for matching rows

CaptainGravyBum

Board Regular
Joined
Dec 1, 2023
Messages
77
Office Version
  1. 365
Platform
  1. Windows
Hello,
I'm in the need of a formula that is eluding me at the moment. From the sheet, I need column D to show the count of column C when column A & B data matches.
The match could be anywhere in the sheet - currently it is in order.
You can see that rows 3&4, 9>11, 14&15 and 23&24 are matched, so I only need the total on one of the rows when this happens - as illustrated.
Thanks in advance
Example.xlsx
ABCD
2Article numberOrder numberCountTotal
3PBB12(MKM1)204021250
4PBB12(MKM1)204021250500
5PFCF11E20401222
6PFCF11E20404566
7PFCF11E2039806060
8PFCF11E2040851010
9PBTF1220412510
10PBTF1220412520
11PBTF1220412550
12PBTF1220412520100
13PBTF122041271010
14PFCF11E20313445
15PFCF11E2031341560
16PBB12(JE1)204136500500
17PBTF122041361010
18PBB12(JE1)204225500500
19PBB12(JE1)204229500500
20PFCF11E2042841010
21PBTF122042785252
22TGB20427877
23PBB12(MKM1)20440230
24PBB12(MKM1)204402300330
25PFCF11E20445022
Sheet1
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
try
Book1
ABCDE
1
2Article numberOrder numberCountTotal
3PBB12(MKM1)204021250 
4PBB12(MKM1)204021250500500
5PFCF11E204012222
6PFCF11E204045666
7PFCF11E203980606060
8PFCF11E204085101010
9PBTF1220412510 
10PBTF1220412520 
11PBTF1220412550 
12PBTF1220412520100100
13PBTF12204127101010
14PFCF11E20313445 
15PFCF11E203134156060
16PBB12(JE1)204136500500500
17PBTF12204136101010
18PBB12(JE1)204225500500500
19PBB12(JE1)204229500500500
20PFCF11E204284101010
21PBTF12204278525252
22TGB204278777
23PBB12(MKM1)20440230 
24PBB12(MKM1)204402300330330
25PFCF11E204450222
Sheet5
Cell Formulas
RangeFormula
E3:E25E3=IF(COUNTIFS($A$3:$A$25,A3,$B$3:$B$25,B3)=COUNTIFS($A$3:$A3,A3,$B$3:$B3,B3), SUMPRODUCT(($A$3:$A$25=$A3)*($B$3:$B$25=$B3)*($C$3:$C$25)),"")
 
Last edited:
Upvote 0
Solution
Hi @awoohaw
Spot on once again, thanks for the fast response.(y)
try
Book1
ABCDE
1
2Article numberOrder numberCountTotal
3PBB12(MKM1)204021250 
4PBB12(MKM1)204021250500500
5PFCF11E204012222
6PFCF11E204045666
7PFCF11E203980606060
8PFCF11E204085101010
9PBTF1220412510 
10PBTF1220412520 
11PBTF1220412550 
12PBTF1220412520100100
13PBTF12204127101010
14PFCF11E20313445 
15PFCF11E203134156060
16PBB12(JE1)204136500500500
17PBTF12204136101010
18PBB12(JE1)204225500500500
19PBB12(JE1)204229500500500
20PFCF11E204284101010
21PBTF12204278525252
22TGB204278777
23PBB12(MKM1)20440230 
24PBB12(MKM1)204402300330330
25PFCF11E204450222
Sheet5
Cell Formulas
RangeFormula
E3:E25E3=IF(COUNTIFS($A$3:$A$25,A3,$B$3:$B$25,B3)=COUNTIFS($A$3:$A3,A3,$B$3:$B3,B3), SUMPRODUCT(($A$3:$A$25=$A3)*($B$3:$B$25=$B3)*($C$3:$C$25)),"")


my pleasure, but please check again. I had missed one of your requirements and made a correction.


Is there a way to use this formula across rows without data in as well? I need to make sure the formula is there ready for the data to be imported because the data is dynamic.
I tried changing the row from 25 to 100 where relevant and all cells where there were values, now show as #value errors.
 
Upvote 0
what is the formula that you put in cell E100?

if you didn't change the references inside the formula to expand the ranges from 25 to 100 the formula will fail.

If you are concerned about ever expanding rows, I suggest you put the data in a table. When you paste new data in a table the formulas automatically expand.
 
Upvote 0
what is the formula that you put in cell E100?

if you didn't change the references inside the formula to expand the ranges from 25 to 100 the formula will fail.

If you are concerned about ever expanding rows, I suggest you put the data in a table. When you paste new data in a table the formulas automatically expand.
Only rows 3 to 25 have data in them currently, the rest are formulas which reference another sheet. So if there are more rows in the second sheet it will pull the data through.
I have tried changing the references in the formula, but it doesn't return any results at all.
I haven't posted the full workbook as it is quite extensive, i'll see what happens to the formulas the next time the data is imported.
 
Upvote 0
Well, i'm not sure what all that means. But, I can say this. If you have different formulas in columns it is the start of a recipe for disaster.
Consistency in effective workbooks is critical. Report sheets should be separate from data sheets if at all possible. There is nothing wrong with formulas in data, as long as it is consistent. If you want to analyze something differently it should be on a new worksheet. (just my two cents, and I'm sure people here may disagree).
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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