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.

1
-1
2
-2
3
-3
4
-4
5
-5
10
10.00 subtotal =SUBTOTAL(9,A2:A12)
-15.00negative hours =SUMIF(A2:A13,"<0")
35.00positive hours =SUMIF(A2:A13,">0")

<tbody>
</tbody>
You can see that the subtotal is being added to the positive hours.

<colgroup><col></colgroup><tbody>
</tbody>
<strike></strike>

<colgroup><col><col></colgroup><tbody>
</tbody>
<strike></strike>


<colgroup><col><col></colgroup><tbody>
</tbody>
=SUMIF(A2:A13,"<0")negative hours
=SUMIF(A2:A13,">0")positive hours

<colgroup><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
why does your formula extend to A13 ?

not exactly sure what your cell entry addresses are, but shouldn't it stop at A12 or even A11 ?

Kind regards,

Chris
 
Upvote 0
As I stated above, there are several categories with subtotals, I only included one in the example. So, after five or so rows there would be a subtotal and then rows six through 20 would have another, etc. Thank-you.
 
Upvote 0
Is there anything in another column that can differentiate between a subtotal row and all other rows?
So you can do something like
=SUMIFS(A2:A13,A2:A3,">0",B2:B13,"<>Subtotal")
 
Upvote 0
I tried it, but, there was an error stating that I entered to few arguments. Thanks for your help though!
-Rix
 
Upvote 0
NO Wait! It worked. I had missed the fact that you referenced the same column twice. In answer to our question, no there is not another column I can reference to differentiate the subtotaled rows, so, I referenced the same column a third time and that did it!

Holy crap, thank-you!

Here are the actual formulas I'm using in the spread sheet:

=SUMIFS($H$8:$H$104,$H$8:$H$104,">0",$H$8:$H$104,"<>Subtotal")
=SUMIFS($H$8:$H$104,$H$8:$H$104,"<0",$H$8:$H$104,"<>Subtotal")


Thanks Again,
-Rix
 
Upvote 0
That makes no sense, and in no way excludes any subtotal values from your sum.
It's excluding any cell containing "Subtotal" in $H$8:$H$104.
That's the same range that you're summing.
So any cell containing "Subtotal" in $H$8:$H$104 will already be excluded...because it's a text string, so it can't be summed in the first place.
 
Upvote 0
Whether it makes sense or not doesn't matter to me. It works. And I'd appreciate it if you would try it yourself before you go casting aspersions upon my post. I'm telling you, it's working for me.
 
Upvote 0
I happen to agree with Jonmo.

You are summing H, based on values on H being >0
SUMIFS will ignore any text entry anyway, so adding that last criteria - based in the same column as the values - is redundant
=SUMIFS($H$8:$H$104,$H$8:$H$104,">0",$H$8:$H$104,"<>Subtotal"))

Jonmo's suggestion was based on the values being in column A and text being in column B.
When someone of Jonmo's level of experience and knowledge (43 000 posts in this forum alone) says something doesnt make sense, newbies (like yourself) and others should make note of that, and try to understand what needs to change to make it make sense. If what you have, is working - given the data you are basing it on- that's fine, but based on your request, that formula you gave may not work on a broader range of data.

Perhaps a sumifs() might be a better option to use instead of the subtotal() anyway?
 
Upvote 0

Forum statistics

Threads
1,215,093
Messages
6,123,066
Members
449,090
Latest member
fragment

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