Sulprobil
Search…
Afreq
If you need to add values for possibly repeating iteams you can take this UDF:
[Please note that GSort was just used to beautify=sort the output.]
Please read my Disclaimer.
Function Afreq(v As Variant) As Variant
'Afreq adds frequencies for possibly repeating items:
'a 4
'a 7
'b 2
'b 3
'will be returned as
'a 11
'b 5
'Array-enter Afreq(A1:B4) into cells C1:D2, for example.
'Reverse("moc.LiborPlus.www") PB V0.2 07-Mar-2009
Dim obj As Object
Dim vR As Variant
Dim i As Long
Set obj = CreateObject("Scripting.Dictionary")
With Application.WorksheetFunction
vR = .Transpose(.Transpose(v))
On Error Resume Next
For i = LBound(vR, 1) To UBound(vR, 1)
obj.Item(vR(i, 1)) = obj.Item(vR(i, 1)) + vR(i, 2)
Next i
Afreq = .Transpose(Array(obj.keys, obj.items))
End With
End Function
Copy link