Hi,
I'm trying to make a function that sums values from calls that have the same outline level. Idea is to calculate only cells until the next upper level cell.
Here is what I have done, but this function seems to be very unefficient when I'm using that in many cells to calculate quite large amount of data.
Do you have any ideas how to make the same more efficient way?
Function OutlineLevelSum(iLevel As Integer, rSumRange As Range)
Dim rCell As Range
Dim vResult
For Each rCell In rSumRange
If Rows(rCell.Row).OutlineLevel = iLevel Then
vResult = vResult + rCell.Value
ElseIf Rows(rCell.Row).OutlineLevel < iLevel Then
Exit For
End If
Next rCell
OutlineLevelSum = vResult
End Function
Bookmarks