excel:macro_sum_sequentially
This is an old revision of the document!
Excel - Macro Sum Sequentially
' Returns the sum of all oArrWithValues for all vCrit found within the array oArrWithCrit. Function ArraySumIfSequential(oArrWithCrit As Variant, vCrit As Variant, oArrWithValues As Variant) Dim vArr1 As Variant Dim vArr2 As Variant Dim lRow As Long If (UBound(oArrWithCrit) - LBound(oArrWithCrit)) = (UBound(oArrWithValues) - LBound(oArrWithValues)) Then For lRow = LBound(oArrWithCrit, 1) To UBound(oArrWithCrit, 1) If oArrWithCrit(lRow, 1) = vCrit Then ArraySumIfSequential = ArraySumIfSequential + oArrWithValues(lRow, 1) End If Next Else ArraySumIfSequential = "Criteriarange and sum range must be of same length" End If ' Clear all objects. Set vArr1 = Nothing Set vArr2 = Nothing End Function
excel/macro_sum_sequentially.1468225433.txt.gz ยท Last modified: 2020/07/15 09:30 (external edit)