Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
On Thu, 8 Nov 2007 11:31:01 -0800, Precious Pearl
wrote: CAN YOU ALPHA SORT IN A SINGLE CELL? You need to use a VBA macro. To enter the macro, <alt-F11 opens the VB Editor. Ensure your project is highlighted in the project explorer window, then Insert/Module and paste the code below into the window that opens. To use this, select the cell(s) you which to sort within the cell. Then <alt-F8 opens the macro dialog box. Select the srt macro and Run. ================================= Option Explicit Sub srt() Dim c As Range For Each c In Selection If Len(c.Text) 0 Then c.Value = bSort(c.Text) Next c End Sub Function bSort(str As String) Dim temp As Variant Dim tempArray() As Variant Dim i As Integer Dim NoExchanges As Integer ReDim tempArray(0 To Len(str) - 1) For i = 1 To Len(str) tempArray(i - 1) = Mid(str, i, 1) Next i ' Loop until no more "exchanges" are made. Do NoExchanges = True ' Loop through each element in the array. For i = 0 To UBound(tempArray) - 1 ' If the element is greater than the element ' following it, exchange the two elements. If tempArray(i) tempArray(i + 1) Then NoExchanges = False temp = tempArray(i) tempArray(i) = tempArray(i + 1) tempArray(i + 1) = temp End If Next i Loop While Not (NoExchanges) bSort = Join(tempArray, "") End Function ======================================== --ron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to sort ascending or descending in multiple entries within one single cell? | Excel Discussion (Misc queries) | |||
Alpha Numeric Sort | Excel Discussion (Misc queries) | |||
Can I change the sort order to Alpha before Numeric? | Excel Discussion (Misc queries) | |||
Alpha sort excel mail list | Excel Discussion (Misc queries) | |||
I want to sort worksheets in a workbook into Alpha order? | Excel Worksheet Functions |