User Tools

Site Tools


excel:macro_sum_sequentially

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
excel:macro_sum_sequentially [2016/07/11 08:23] – created peterexcel:macro_sum_sequentially [2016/07/11 11:33] (current) – removed peter
Line 1: Line 1:
-====== Excel - Macro Sum Sequentially ====== 
- 
-<code excel> 
-' 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 
-</code> 
  
excel/macro_sum_sequentially.1468225433.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki