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.
1
Function Afreq(v As Variant) As Variant
2
'Afreq adds frequencies for possibly repeating items:
3
'a 4
4
'a 7
5
'b 2
6
'b 3
7
'will be returned as
8
'a 11
9
'b 5
10
'Array-enter Afreq(A1:B4) into cells C1:D2, for example.
11
'Reverse("moc.LiborPlus.www") PB V0.2 07-Mar-2009
12
Dim obj As Object
13
Dim vR As Variant
14
Dim i As Long
15
16
Set obj = CreateObject("Scripting.Dictionary")
17
With Application.WorksheetFunction
18
vR = .Transpose(.Transpose(v))
19
On Error Resume Next
20
For i = LBound(vR, 1) To UBound(vR, 1)
21
obj.Item(vR(i, 1)) = obj.Item(vR(i, 1)) + vR(i, 2)
22
Next i
23
Afreq = .Transpose(Array(obj.keys, obj.items))
24
End With
25
End Function
Copied!
Last modified 1yr ago
Copy link