View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel[_472_] joel[_472_] is offline
external usenet poster
 
Posts: 1
Default how to sort a string?


Try This code.

Sub SortData()

InputStr = "bv-8,ok-3,bv-5,sk-1,bh-2,ok-9"
'put data into an array
SortArray = Split(InputStr, ",")

For I = LBound(SortArray) To (UBound(SortArray) - 1)
For J = (I + 1) To UBound(SortArray)
If SortArray(I) SortArray(J) Then
temp = SortArray(I)
SortArray(I) = SortArray(J)
SortArray(J) = temp
End If
Next J
Next I

OutputStr = Join(SortArray, ",")
End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=166528

Microsoft Office Help