Check an example:
Dim myString As String
myString = "A09D, B04B, Y02B, A09D, W03, E02"
' split '
Dim a
a = Split(myString, ",")
For i = LBound(a) To UBound(a)
a(i) = Trim(a(i))
Next i
' sort '
For i = LBound(a) To UBound(a) - 1
For j = i + 1 To UBound(a)
If a(i) > a(j) Then
Dim t
t = a(i)
a(i) = a(j)
a(j) = t
End If
Next j
Next i
' remove duplicates '
i = LBound(a)
For j = i + 1 To UBound(a)
If a(j) <> a(i) Then
i = i + 1
a(i) = a(j)
End If
Next
ReDim Preserve a(i)
' join '
Dim result As String
result = ""
For i = LBound(a) To UBound(a)
If result <> "" Then result = result & ", "
result = result & a(i)
Next
MsgBox result
Improve it to work in case of empty string.