Subtotal and sum if ?

KevBarry

New Member
Joined
Sep 12, 2018
Messages
7
Have tried (and googled) this before without success so here goes.

Rough example:
I have a number of projects with a filter applied at ROW 4, what is the formula in C2/C3 that will generate the totals when the filter is active?

Thanks in advance
Kev




[TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD][/TD]
[TD]Narrative[/TD]
[TD]Totals[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[TD]Income[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD][/TD]
[TD]Expenditure[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Project #[/TD]
[TD]Narrative[/TD]
[TD]Value[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]A[/TD]
[TD]Income[/TD]
[TD]1000[/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]A[/TD]
[TD]Expenditure[/TD]
[TD]500[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]B[/TD]
[TD]Income[/TD]
[TD]2000[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]B[/TD]
[TD]Expenditure[/TD]
[TD]300[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Code:
=sumproduct(subtotal(3,offset($b$6,row($b$6:$b$9)-row($b$6),,,))*($c$6:$c$9)*($b$6:$b$9=b3))
 
Upvote 0
Thanks for your reply but I am confused by your $b$6 reference as that does not make any logical sense to me ??? would you not be looking at B2 for income or B3 for expenditure?
 
Upvote 0
Sorry I had a different setup of cells in my sheet.

In C2 use this
Code:
=SUMPRODUCT(SUBTOTAL(3,OFFSET($B$5,ROW($B$5:$B$8)-ROW($B$5),,,))*($C$5:$C$8)*($B$5:$B$8=B2))
 
Upvote 0
A little less expensive...


Book1
ABC
1NarrativeTotals
2Income3000
3Expenditure800
4Project #NarrativeValue
5AIncome1000
6AExpenditure500
7BIncome2000
8BExpenditure300
Sheet1


In C2 enter and copy down to C3:

=SUMPRODUCT(SUBTOTAL(9,OFFSET($C$5,ROW($C$5:$C$200)-ROW($C$5),0)),--($B$5:$B$200=$B2))
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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