View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Can you sort one cell or a string in vba?

You need to perfrom a buble sort manually using code

Sub bubbleSort()

Mystring = "14386ah"

For i = 1 To (Len(Mystring) - 1)
For j = (i + 1) To Len(Mystring)

char_i = Mid(Mystring, i, 1)
char_j = Mid(Mystring, j, 1)

If Asc(char_i) Asc(char_j) Then
'switch character
Mid(Mystring, i, 1) = char_j
Mid(Mystring, j, 1) = char_i
End If
Next j
Next i
End Sub

"John" wrote:

Say you have a string="14386ah"
Is there a excel vba function that will sort the string?

Thanks
JOhn