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