Subtotal formula Subtotals greater than zero needed.

Fin Fang Foom

Well-known Member
Joined
Mar 20, 2005
Messages
598
Is there a Subtotal(9, formula that it will only Subtotal greater than zero?
I tried this but does'nt work.

Any Ideas?

=IF(SUBTOTAL(9,S3:S86)>0,SUBTOTAL(9,S3:S86),0)
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Fin,

I) In what way is the solution not working. Do you get an error message, if so which one? Do you get an incorrect value? If so why is it incorrect.

II) Did you make sure to confirm the array formula,
=SUM(--NOT(hidden(A2:A20))*(A2:A20>0)*A2:A20)
with control + alt + enter

Otherwise:

1) Did you insert a module.
2) Copy the FUNCTION (not a sub) exactly as written?
3) test it on a single cell to make sure the Hidden() function works for you.
e.g. enter =Hidden(A2)
Should return False if A2 is visible and True if it is not.
4) Test it on a Range of Cells, e.g. =Hidden(A2:A10) confirmed with Control + Shift + Enter
Confirm it down across multiple cells.
You should see Trues Corresponding to the hidden cells, and false corresponding to the visible cells. (use autofilter to hide and unhide the cells in A2:A10)

In the example I have contrived, the function sums all values within a range that are Positive and Note Hidden.

If you have tried all of the above, could you post a small 5 line or so example, including a negative number that is not hidden and a row to be hidden.

Post the result you are expecting to get, and the result you are getting from my Array Entered Formula.

Paddy is right, You may want to reavaluate the way you set up your data.
 
Upvote 0
The formula gave me 13.16. It should give me 6.44.

I did insert the module under the workbook as a Function.

What I'm doing wrong?
 
Upvote 0
.23 + 1.69 + 4.01 + 5.94 + .50 + .50 = 13.16

The formula is doing what I expected it to do. It summed all visible rows greater than 0.

How do you arrive at 6.44?
Am I missing something?
 
Upvote 0
I only want a grand subtotal formula to subtotal U16 and U20 because those are Subtotal formulas and there are positive values.

Do you think that could be done?
 
Upvote 0
Try this UDF:

Code:
Function MyPositiveSubtotals(rng As Range) As Double
Dim IndVal As Range
Dim Total, CurrentSub As Double
Dim ArrResult() As String, ArrElemt As Integer
'Dimension the array for the # elements you need
ReDim ArrResult(1 To rng.Cells.Count)

'Loop through each cell in the range
For Each IndVal In rng
    ArrElemt = ArrElemt + 1 'counter for the array
    If IndVal.Rows.Height = 0 Or IndVal.Columns.Width = 0 Then
       ArrResult(ArrElemt) = True
    Else
       ArrResult(ArrElemt) = False
    End If
Next IndVal
ArrElemt = 0
Total = 0
For Each IndVal In rng
ArrElemt = ArrElemt + 1
  If Len((IndVal.Offset(1, 0).Value)) = 0 And ArrResult(ArrElemt) = False Then
     If CurrentSub > 0 Then Total = Total + CurrentSub
     CurrentSub = 0
  Else
     If ArrResult(ArrElemt) = False Then CurrentSub = CurrentSub + IndVal.Value
     If ArrResult(ArrElemt) = False And Len((IndVal.Offset(0, 0).Value)) = 0 Then CurrentSub = 0
  End If
Next IndVal
MyPositiveSubtotals = Total
End Function
 
Upvote 0
The function gives me a #NAME? error.

I'am I suppose to use this formula?

=SUM(--NOT(hidden(U4:U23))*(U4:U23>0)*U4:U23)
 
Upvote 0

Forum statistics

Threads
1,223,671
Messages
6,173,735
Members
452,531
Latest member
Dufus1024

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