Thursday, January 17, 2013

SUMIFOR

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
   
  Next Acell
     
    SumIfOr = Subtotal
   
End Function
 
This could be easily modified to work as a CountIfOr as well.