SUBTOTAL and IF

BuzzG

Board Regular
Joined
Sep 8, 2002
Messages
67
I have a database with subtotals for certain columns and auto filters for row filtering. The subtotal function is handy for getting totals for only the visible cells. Can you use the subtotal function in conjunction with a criteria? (something like "SUBTOTALIF"). I want to get sum information on the visible cells but also want exclude the values that do not satisfy the "IF" criteria. Any suggestions?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
try this:

=if(subtotal(A1:A12=whatever,"",(subtotal(A1:A12)

something like that although i havent used subtotal before so you may need to adjust it

HTH
 
Upvote 0
The criteria is in an another column. I need a formula that solves:
"Subtotal range C2:C50 if range B2:B50 is >0". I want to use the SUMIF logic but with filtering flexibility of the SUBTOTAL function.
BuzzG
 
Upvote 0
BuzzG said:
The criteria is in an another column. I need a formula that solves:
"Subtotal range C2:C50 if range B2:B50 is >0". I want to use the SUMIF logic but with filtering flexibility of the SUBTOTAL function.
BuzzG

Insert a column and put this in row 2
=IF(B2>0,C2,0)

Copy this down to row 50 and then use your subtotal on that column. Excel does not have a SUMIF capability in conjunction with SUBTOTAL.

Best regards,
 
Upvote 0
Barrie is it not possible to use something like this:

=if(subtotal(A1:A12=whatever,"",(subtotal(A1:A12)

this in theory gives you a subtotalIF :)
 
Upvote 0
Barrie's solution will work. I was just hoping for a fancy SUBTOTALIF solution from Microsoft.
Thanks for your help
BuzzG
 
Upvote 0
BuzzG said:
The criteria is in an another column. I need a formula that solves:
"Subtotal range C2:C50 if range B2:B50 is >0". I want to use the SUMIF logic but with filtering flexibility of the SUBTOTAL function.
BuzzG

=SUMPRODUCT(SUBTOTAL(3,OFFSET(C2:C50,ROW(C2:C50)-MIN(ROW(C2:C50)),,1)),--(B2:B50>0),C2:C50)
 
Upvote 0
I am using this formula and trying to get to do one more thing:

=SUMPRODUCT(SUBTOTAL(3,OFFSET(F14:F61,ROW(F14:F61)-MIN(ROW(F14:F61)),,1)),--(J14:J61="Facility Design"),F14:F61)

I want to subtotal F14:F61 only if it equals 100% and has "Facility Design" in another column. I have tried different things but am rather new to the world of formulas.

I dont even know if I need such a complex formula for my needs. I just to total the 100% in a column only if another column has "blah blah".

Any insight would be great. Thanks.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

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