Petros, here is a modification of something similar I had to do. It uses a dictionary object to hold the unique keys which are then concatenated back into the result. Once you create it, you can use it like any other function. I don't really have a lot of time right now, so there is no error handling.
Function UniqueValsInCell(ByVal Target As Range)
Dim i As Integer
Dim Dictionary As Object
Dim arKeys() As Variant
Dim arVals() As String
Dim strReturn As String
Set Dictionary = CreateObject("Scripting.dictionary")
arVals() = Split(Target.Value, ",")
strReturn = ""
For i = 0 To UBound(arVals()) Step 1
If Not Dictionary.exists(Trim(arVals(i))) Then
Dictionary.Add Trim(arVals(i)), 1
End If
Next i
arKeys = Dictionary.keys
For i = LBound(arKeys()) To UBound(arKeys()) Step 1
If strReturn = "" Then
strReturn = arKeys(i)
Else
strReturn = strReturn & ", " & arKeys(i)
End If
Next i
UniqueValsInCell = strReturn
End Function
Greg
Bookmarks