Option Explicit
Function SortCell(rng As Range, Optional Delimiter As String) As String
Dim arr() As String, arrTmp() As String, i As Long
If rng.Text = "" Then Exit Function
If Delimiter = "" Then Delimiter = ","
If InStr(1, rng.Text, Delimiter) = 0 Then
SortCell = rng.Text
Exit Function
End If
arr = Array_Sort(Split(rng.Text, Delimiter))
For i = LBound(arr) To UBound(arr)
SortCell = SortCell & arr(i) & ","
Next i
SortCell = Left(SortCell, Len(SortCell) - 1)
End Function
Private Function Array_Sort(ByVal NotSortedArry As Variant) As Variant
'Originally coded by Masaru Kaji: http://puremis.net/excel/code/022.shtml
Dim i As Long, j As Long, vElm As Variant
For i = LBound(NotSortedArry) To UBound(NotSortedArry)
For j = i + 1 To UBound(NotSortedArry)
If NotSortedArry(i) > NotSortedArry(j) Then
vElm = NotSortedArry(j)
NotSortedArry(j) = NotSortedArry(i)
NotSortedArry(i) = vElm
End If
Next
Next
Array_Sort = NotSortedArry
End Function