G
Guest
I have the following user defined function set up in a workbook and it works
fine but I would like to take it one step further.
Option Explicit
Function SortText(myStr As String) As String
Dim mySplit As Variant
Dim iCtr As Long
Dim jCtr As Long
Dim Temp As Variant
mySplit = Split(myStr, " ")
For iCtr = LBound(mySplit) To UBound(mySplit) - 1
For jCtr = iCtr + 1 To UBound(mySplit)
If mySplit(iCtr) > mySplit(jCtr) Then
Temp = mySplit(iCtr)
mySplit(iCtr) = mySplit(jCtr)
mySplit(jCtr) = Temp
End If
Next jCtr
Next iCtr
SortText = Join(mySplit, " ")
End Function
I would like to have some code that would sort the data in the cells (column
E) without having to add a new column to either place the sorted data or to
hold the sorted data. The data in coulmn E looks like this:
AAI BII TTU QQS AAC NUY GGE BBT
I need those 3 digit (sometimes 4 digit codes) sorted in alpha order. The
number of rows is never the same.
fine but I would like to take it one step further.
Option Explicit
Function SortText(myStr As String) As String
Dim mySplit As Variant
Dim iCtr As Long
Dim jCtr As Long
Dim Temp As Variant
mySplit = Split(myStr, " ")
For iCtr = LBound(mySplit) To UBound(mySplit) - 1
For jCtr = iCtr + 1 To UBound(mySplit)
If mySplit(iCtr) > mySplit(jCtr) Then
Temp = mySplit(iCtr)
mySplit(iCtr) = mySplit(jCtr)
mySplit(jCtr) = Temp
End If
Next jCtr
Next iCtr
SortText = Join(mySplit, " ")
End Function
I would like to have some code that would sort the data in the cells (column
E) without having to add a new column to either place the sorted data or to
hold the sorted data. The data in coulmn E looks like this:
AAI BII TTU QQS AAC NUY GGE BBT
I need those 3 digit (sometimes 4 digit codes) sorted in alpha order. The
number of rows is never the same.