Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default alphabetizing/sorting text within a cell

hi,

does anybody know how to alphabetize groups of words within a cell (by
first letter of the word)?

for instance, in a cell i have the words "dog bird cat" and after
alphabetization it would come out as "bird cat dog"

any help would be appreciated :) thanks

  #2   Report Post  
Posted to microsoft.public.excel.misc
JMB
 
Posts: n/a
Default alphabetizing/sorting text within a cell

You could use Text To Columns (delimiter = space) to split the data. Then
use Excel's sort (Data/Sort), and concatenate the items back together into
one string. Another possibility is to try a User Defined Function.

Function MySort(rngCell As Range) As String
Dim arrData As Variant
Dim i As Long
Dim t As Long
Dim strTemp As String

arrData = Split(rngCell.Value, " ", -1, vbTextCompare)

For i = LBound(arrData) To UBound(arrData) - 1
For t = i + 1 To UBound(arrData)
If LCase(CStr(arrData(t))) < LCase(CStr(arrData(i))) Then
strTemp = arrData(i)
arrData(i) = arrData(t)
arrData(t) = strTemp
End If
Next t
Next i

MySort = Join(arrData, " ")

End Function

" wrote:

hi,

does anybody know how to alphabetize groups of words within a cell (by
first letter of the word)?

for instance, in a cell i have the words "dog bird cat" and after
alphabetization it would come out as "bird cat dog"

any help would be appreciated :) thanks


  #3   Report Post  
Posted to microsoft.public.excel.misc
 
Posts: n/a
Default alphabetizing/sorting text within a cell

Thanks, the function worked really well!

  #4   Report Post  
Posted to microsoft.public.excel.misc
JMB
 
Posts: n/a
Default alphabetizing/sorting text within a cell

Glad to help

" wrote:

Thanks, the function worked really well!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell Capacity - text i2meek Excel Discussion (Misc queries) 4 March 13th 06 01:06 AM
How can I make an excel cell equal to the value of a frame object text box directionalman Excel Worksheet Functions 1 February 27th 06 10:24 PM
Cell text based on 4 condition test Bob Wall Excel Worksheet Functions 3 November 16th 05 08:34 PM
Autofitting a row Josephine Excel Discussion (Misc queries) 2 March 3rd 05 04:37 PM
Formatting a cell as "text" in the number catagory. Ed Excel Worksheet Functions 3 December 7th 04 08:12 PM


All times are GMT +1. The time now is 08:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"