I am a supporter of
St. Joseph's hospice.
 If you find this site useful or if it helped you, consider a small donation to
St. Joseph's, please.

Information on
St. Joseph's

JustGiving - Sponsor me now!

 

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.]

Afreq_Example

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 'Please read
                               'http://www.sulprobil.com/Get_it_done/IT/Excel_Fun/Excel_VBA/Error_Trapping/error_trapping.html

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

Sulprobil   Get it done   Contact   Disclaimer   Download