Exclude Subtotal Amounts from a sumif formula.

RixRox

New Member
Joined
Sep 19, 2017
Messages
13
I have negative and positive numbers (hours) that I want to sum from several categories on my spread sheet. Each category has a subtotal.

I want to sum both positive and negative hours in one column (start to finish) without including the subtotals. Any help would be much appreciated. Thank-you.

[TABLE="width: 400"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD][TABLE="width: 1146"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD][TABLE="width: 180"]
<colgroup><col></colgroup><tbody>[TR]
[TD] 1[/TD]
[/TR]
[TR]
[TD] -1[/TD]
[/TR]
[TR]
[TD] 2[/TD]
[/TR]
[TR]
[TD] -2[/TD]
[/TR]
[TR]
[TD] 3[/TD]
[/TR]
[TR]
[TD] -3[/TD]
[/TR]
[TR]
[TD] 4[/TD]
[/TR]
[TR]
[TD] -4[/TD]
[/TR]
[TR]
[TD] 5[/TD]
[/TR]
[TR]
[TD] -5[/TD]
[/TR]
[TR]
[TD] 10[/TD]
[/TR]
[TR]
[TD][TABLE="width: 573"]
<tbody>[TR]
[TD]10.00 [/TD]
[TD]subtotal =SUBTOTAL(9,A2:A12)[/TD]
[/TR]
[TR]
[TD]-15.00[/TD]
[TD]negative hours =SUMIF(A2:A13,"<0")[/TD]
[/TR]
[TR]
[TD]35.00[/TD]
[TD]positive hours =SUMIF(A2:A13,">0")[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD]You can see that the subtotal is being added to the positive hours.[/TD]
[/TR]
</tbody>[/TABLE]
<strike></strike>
[TABLE="width: 573"]
<colgroup><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
<strike></strike>

[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]=SUMIF(A2:A13,"<0")[/TD]
[TD]negative hours[/TD]
[/TR]
[TR]
[TD]=SUMIF(A2:A13,">0")[/TD]
[TD]positive hours[/TD]
[/TR]
</tbody>[/TABLE]
 
As a matter of fact, I did test it.
I did it again now, and here are the results.

It does not ignore the subtotals.

Book1
HIJ
872583
998-187
10-41
1110
12Subtotal
13139
14-12
15-18
16-17
1750
1842
19Subtotal
2045
21-99
2292
2321
24Subtotal
2514
Sheet1
Cell Formulas
RangeFormula
J8=SUMIFS($H$8:$H$104,$H$8:$H$104,">0",$H$8:$H$104,"<>Subtotal")
J9=SUMIFS($H$8:$H$104,$H$8:$H$104,"<0",$H$8:$H$104,"<>Subtotal")
H13=SUBTOTAL(9,H8:H11)
H20=SUBTOTAL(9,H13:H18)
H25=SUBTOTAL(9,H20:H23)
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Now if you DO have the word Subtotal within the same column as the numbers you want to sum.
Are those words one cell above the actual subtotal formula?

In my example above, H12 has the word subtotal, then H13 has the actual subtotal formula.
If that is the pattern you have as well, you can offset the criteria range testing for the word subtotal.
=SUMIFS($H$8:$H$104,$H$8:$H$104,">0",$H$7:$H$103,"<>Subtotal")
 
Upvote 0
I'm not the experts guys, I just came here looking for help. Here are two screenshots of the excel template. If you can figure out why it does or doesnt work, great. All I know is that it works perfectly. I think the confusion lies in the way I'm using it. I'm summing the totals in separate areas.

36638946153_bd0b5644f9_b.jpg
[/URL]One by Rick Baehre, on Flickr[/IMG]

36638946033_c9b2d8bdd6_c.jpg
[/URL]two by Rick Baehre, on Flickr[/IMG]
 
Upvote 0
I'm not the experts guys, I just came here looking for help. Here are two screenshots of the excel template. If you can figure out why it does or doesnt work, great. All I know is that it works perfectly. I think the confusion lies in the way I'm using it. I'm summing the totals in separate areas.

36638946153_bd0b5644f9_b.jpg
[/URL]One by Rick Baehre, on Flickr[/IMG]

36638946033_c9b2d8bdd6_c.jpg
[/URL]two by Rick Baehre, on Flickr[/IMG]

This example shows some positive values (same formulas):
37261631776_066798b893_z.jpg
[/URL]Untitled by Rick Baehre, on Flickr[/IMG]
 
Upvote 0
According to your pictures, you DO have another column that can be used to indicate which rows are subtotals. Like I asked for in the beginning.
Look at all those columns on the left that say "Subtotal of Direct Labor..."
That is Perfect.

Try this, assuming column G contains those strings.
=SUMIFS($H$8:$H$104,$H$8:$H$104,">0",$G$8:$G$104,"<>Subtotal*")
 
Upvote 0
Column G is for Shop hours and Column H is for Field hours. and wont, necessarily be the same. It works perfectly the way it is, just accept it, lol. Again, I thank you for your help!!!
 
Upvote 0
No, I won't. And you shouldn't either.
I'm trying to help you.

That formula is NOT doing what you think it's doing. It is NOT ignoring subtotals.
Look, your sumifs for >0 is returning 13,680
I can only come up with 13,680 if I add ALL the values, INCLUDING your subtotals.

According to the picture, the values >0 that are NOT subtotals in that column, the sum should be 9360.


The picture doesn't help a lot because I can't see column and row headers. So I don't know which values are within the ranges specified by your formulas.

That column on the left (regardless if it's used for something else) does seem to indicate which rows are subtotals.
You should use that to your advantage as suggested.
 
Upvote 0
If Column G is Shop Hours, then it's column D (Description) that should be used in the last formula I suggested.
Column D contains the strings like "Subtotal of Direct Labor..."

=SUMIFS($H$8:$H$104,$H$8:$H$104,">0",$D$8:$D$104,"<>Subtotal*")
 
Last edited:
Upvote 0
Yep, I see it now ... I've been looking for the perfect formula for so long, I saw a mirage and I drank the sand.

I tried inserting the formula you suggested, where you suggested, to no avail. Perhaps I put it in the wrong cell; Also, I have many columns (with subtotals) to sum, not just the labor columns, so I have returned to my original formula(s).

Calculated from I:118 =SUMIF(I7:I63,">0")+SUMIF(I65:I73,">0")+SUMIF(I75:I83,">0")+SUMIF(I85:I88,">0")+SUMIF(I90:I103,">0")+SUMIF(I105:I114,">0") which calculates the correct number ever so manually...

Thanks for your patience.

Picture with reference:
36604574714_ccd2decffd_b.jpg

and,
36638946033_fd7b76dc44_o.jpg
 
Last edited:
Upvote 0
OK, it looks like it's column B that contains those text strings beginning with the word subtotal.
Try
=SUMIFS(I7:I114,I7:I114,">0",B7:B114,"<>Subtotal*")
 
Upvote 0

Forum statistics

Threads
1,224,852
Messages
6,181,405
Members
453,036
Latest member
Koyaanisqatsi

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