Inside Cell Sorting

jimblimm

Board Regular
Joined
May 11, 2012
Messages
219
I have the following data in cell a1

A1=eeoe

i would like to have a formula that will sort A1 data in A2 alphabetically

A2 should = eeeo

i would prefer a formula instead of Vba
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
I know you prefer a worksheet formula, but in the event you don't get one in a response, here's a user-defined function (UDF) that you can use like a worksheet function as in the example below.
Excel Workbook
A
1eeoe
2eeeo
Sheet6



To install the UDF:
1. With your workbook active press Alt and F11 keys. This will open the VBE window.
2. In the project tree on the left of the VBE window, find your project and click on it.
3. On the VBE menu: Insert>Module
4. Copy the UDF from your browser window and paste it into the white space in the VBE window.
5. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
6. Use the UDF as you would any native Excel function.
7. Make sure you have enabled macros whenever you open the file or the code will not run.
Code:
Function SortCell(S As String) As String
Dim aList As Object, i As Long
Set aList = CreateObject("System.Collections.ArrayList")
If Len(S) > 1 Then
    For i = 1 To Len(S)
        aList.Add Mid(S, i, 1)
    Next i
    aList.Sort
    SortCell = Join(aList.toarray(), "")
Else
    SortCell = S
End If
End Function
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top