Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtotal

Status
Not open for further replies.

sqlwp

Programmer
Joined
Jan 23, 2004
Messages
24
Location
US
I need to do a conditional subtotal on a field. If any cell in column A is the value "R" then sum the associated value in column B. How can I accomplish this with a subtotal? I need to use subtotal because autofiltering can be used on many different columns.
 
Hi sqlwp,

Why not use Column C to contain all those Col B items which have an "R" in Col A, then use a Subtotal on col C.

Good Luck!
Peter Moran
 
sounds like you need to look into the SUMIF function rather than a subtotal - I get the impression that your "R"s could be anywhere in the column

Rgds, Geoff

"Having been erased. the document thjat you are seeking. Must now be retyped"

Please read FAQ222-2244 before you ask a question
 
I could split out the value in column B based on the value in column A and subtotal those columns individually, but this spreadsheet is huge and contains many columns that I have to total based on this condition so I would rather not have to do that.
I have to use the subtotal function because the spreadsheet can be filtered on by many different fields and the totals need to reflect only those records that are being filtered, that's why I can't use the sumif.
 
So, why can't you filter on column A being "R"?




Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
I don't know how to tell the subtotal command to look at every cell in column A for an "R" and sum the associated value in column B. If I use a condition with the subtotal it only looks at one cell:
=IF(A12="R",(SUBTOTAL(9,B12:B45623)),0)
How do I give it a range condition?
 
=SUMPRODUCT((A1:A1000="R")*(B1:B1000))

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 
If you filter on column A being "R" then the SUBTOTAL function will only include the displayed rows. Isn't that what you want?



Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
The sumproduct formula doesn't work if autofilter is used on any of the fields in the worksheet, that's why I need to use subtotal.
 
Hi sqlwp,

again I ask, why can't you filter on column A?


Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
Because there are other subtotals that need all values for column A.
 
In that case PeterMoran gave you the answer near the top of this thread.


Cheers, Glenn.

Did you hear about the literalist show-jumper? He broke his nose jumping against the clock.
 
That would certainly work but I would have to do it for over 10 columns that I'm trying to subtotal. I was looking for a way to do it more dynamically through a formula.
It looks like that might not be possible.
 
Well - if your process is inflexible then you will always run the risk of having to carry out more manual tasks !

Rgds, Geoff

"Having been erased. the document thjat you are seeking. Must now be retyped"

Please read FAQ222-2244 before you ask a question
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top