Is this the right direction?
I found this but it puts each individual digit in order and without spaces. Could it maybe be modified? The string will always consist of 4 digit numbers (Years). Even if each group of four digits could be grouped together and sorted without spaces I could maybe add spaces after sorting. Thanks
Private Function SortCharacters(theString As String) As String
Dim currentChar As String
Dim sourceNum As Integer
Dim destNum As Integer
For sourceNum = 1 To Len(theString)
currentChar = Mid(theString, sourceNum, 1)
If sourceNum = 1 Then
SortCharacters = currentChar
Else
destNum = 1
While destNum <= Len(SortCharacters) And currentChar > Mid(SortCharacters, destNum, 1)
destNum = destNum + 1
Wend
SortCharacters = Left(SortCharacters, destNum - 1) & currentChar & Mid(SortCharacters, destNum)
End If
Next sourceNum
End Function
Private Function SortCharacters(theString As String) As String
Dim currentChar As String
Dim sourceNum As Integer
Dim destNum As Integer
For sourceNum = 1 To Len(theString)
currentChar = Mid(theString, sourceNum, 1)
If sourceNum = 1 Then
SortCharacters = currentChar
Else
destNum = 1
While destNum <= Len(SortCharacters) And currentChar > Mid(SortCharacters, destNum, 1)
destNum = destNum + 1
Wend
SortCharacters = Left(SortCharacters, destNum - 1) & currentChar & Mid(SortCharacters, destNum)
End If
Next sourceNum
End Function
|