
Viorel 113.8K Reputation points
20220407T17:37:32.893+00:00 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.
Thanks for sharing. It's really helpful for my current task Technoblade merch store. I am happy to view this type of logic.