Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
if i have a list of letters in a cell, is it possible to alphabetize
them? example: ADCB -- ABCD |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
This will sort A1 into A2 Sub gg() x = Len(Cells(1, 1)) Cells(2, 1).ClearContents For i = 1 To x Cells(i, 2) = Mid(Cells(1, 1), i, 1) Next i Cells(1, 2).Resize(x).Sort Key1:=Cells(1, 2), Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom For i = 1 To x Cells(2, 1) = Cells(2, 1) & Cells(i, 2) Cells(i, 2).ClearContents Next i End Sub Mike " wrote: if i have a list of letters in a cell, is it possible to alphabetize them? example: ADCB -- ABCD |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Feb 14, 1:13 pm, Mike H wrote:
Hi, This will sort A1 into A2 Sub gg() x = Len(Cells(1, 1)) Cells(2, 1).ClearContents For i = 1 To x Cells(i, 2) = Mid(Cells(1, 1), i, 1) Next i Cells(1, 2).Resize(x).Sort Key1:=Cells(1, 2), Order1:=xlAscending, _ Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom For i = 1 To x Cells(2, 1) = Cells(2, 1) & Cells(i, 2) Cells(i, 2).ClearContents Next i End Sub Mike " wrote: if i have a list of letters in a cell, is it possible to alphabetize them? example: ADCB -- ABCD Is there a way that this can work in any cell, first of all. second, can it Change ABaD -- AaBD and not ABDa. third, can it output to the same cell as the input if not, could it go to an identical position (ex: D7) on a different worksheet |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use the following as a UDF, like this
=SortLetters(A1) Option Explicit '' to sort like a=A use Option Compare Text ' or to sort like ABCabc don't Option Compare Text Function SortLetters(v As Variant) As String Dim bFlag As Boolean Dim n As Long, i As Long Dim s As String n = Len(v) If n = 0 Then Exit Function ReDim arrS(0 To Len(v)) For i = 1 To Len(v) arrS(i) = Mid$(v, i, 1) Next Do bFlag = True For i = LBound(arrS) To UBound(arrS) - 1 If arrS(i) arrS(i + 1) Then bFlag = False arrS(0) = arrS(i) arrS(i) = arrS(i + 1) arrS(i + 1) = arrS(0) End If Next i Loop While Not bFlag s = "" For i = 1 To UBound(arrS) s = s & arrS(i) Next SortLetters = s End Function Regards, Peter T wrote in message ... if i have a list of letters in a cell, is it possible to alphabetize them? example: ADCB -- ABCD |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
alphabetize | New Users to Excel | |||
alphabetize | Excel Discussion (Misc queries) | |||
alphabetize - automatically | Excel Worksheet Functions | |||
Alphabetize? | Excel Discussion (Misc queries) | |||
Alphabetize a sort. | Excel Discussion (Misc queries) |