Sum, If, Or: My modification of the SumIf where I needed to add a range of items.
Function SumIfOr(CompareRange As range, CriteriaRange As range, SumRange As range)
Dim Subtotal As Double
Dim Acell As range
Subtotal = 0
For Each Acell In CriteriaRange
Subtotal = Application.SumIf(CompareRange, Acell.Value, SumRange) + Subtotal
Dim Subtotal As Double
Dim Acell As range
Subtotal = 0
For Each Acell In CriteriaRange
Subtotal = Application.SumIf(CompareRange, Acell.Value, SumRange) + Subtotal
Next Acell
SumIfOr = Subtotal
End Function
SumIfOr = Subtotal
End Function
This could be easily modified to work as a CountIfOr as well.
No comments:
Post a Comment