microsoft_excel:macro_count_sequentially
This is an old revision of the document!
Microsoft Excel - Macro Count Sequentially
' Returns the number of vCrit found within the array oArrWithCrit. Function ArrayCountIfSequential(oArrWithCrit As Variant, vCrit As Variant) Dim lRow As Long For lRow = LBound(oArrWithCrit, 1) To UBound(oArrWithCrit, 1) If oArrWithCrit(lRow, 1) = vCrit Then ArrayCountIfSequential = ArrayCountIf + 1 End If Next End Function
or
'=ArrayCountIf(A1:A1000,"Foo",B1:B1000) Function RangeCountIf(oRngWithCrit As Range, vCrit As Variant) Dim vArr1 As Variant Dim lRow As Long vArr1 = oRngWithCrit.Value For lRow = LBound(vArr1, 1) To UBound(vArr1, 1) If vArr1(lRow, 1) = vCrit Then RangeCountIf = RangeCountIf + 1 End If Next ' Clear all objects. Set vArr1 = Nothing End Function
microsoft_excel/macro_count_sequentially.1468236113.txt.gz · Last modified: 2020/07/15 09:30 (external edit)