Help with formula to "FIND" numbers within a cell that contains other numbers

TheReaper

New Member
Joined
Aug 18, 2009
Messages
10
Hello guys!
How is it going?

I'm looking for your precious help again with a formula to "Find" some characters. I hope you could guide me through...

Here is what I need to do:

- I have a database with cells that contains a series of "names" within each cell... I need to sort (alphabetically) them alphabetically. -Not to sort the cells, to sort the content within the cells... you know, concatenate them alphabetically. Here is an example of the text within a cell:

+++++++++++++++++++++++++++++++++++++++++++++++++++++
Sciences; Engineering & Applied Sciences; Arts, Architecture & Applied Arts; Social Sciences; Law, Politics & Government; General; Business & Economics; Journalism & Communications; Health Sciences; Languages & Literatures
+++++++++++++++++++++++++++++++++++++++++++++++++++++

I need to sort that content alphabetically. Each ";" is the separator between concepts.

==============================================
I've been trying to replace each name with numbers to make it easier (i.e. Sciences = 12), and I get a result like: 12,3,1,13,9,4,2,7,5,8
(Max value is 13)

That's when I got stuck!...
First I tried a formula to look for each number, however, formula stops after each "," (comma). FAILURE!

For example, in a column I placed a formula to look for the number "1", then, in another column to look for number "2", and so on. But if the number I'm looking for is before or after a comma, it returns me an error.

============================
Then, I tried to extract each number and later (somehow) concatenate them with the proper sort... I'm using a series of formulas to do that, but then I get errors after the first two-digit numbers. FAILURE!

Hope someone could help me! Thanks in advance guys you're amazing!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Assuming that your list is in column A try this macro

Code:
Sub alphabet()
Dim X As Variant, k As Long, LR As Long
Dim First As Long, Last As Long
Dim i As Long, j As Long, Temp As Variant
Application.ScreenUpdating = False
LR = Range("A" & Rows.Count).End(xlUp).Row
For k = 1 To LR
    With Range("A" & k)
        X = Split(.Value, ";")
            First = LBound(X)
            Last = UBound(X)
            For i = First To Last - 1
                For j = i + 1 To Last
                    If X(i) > X(j) Then
                        Temp = X(j)
                        X(j) = X(i)
                        X(i) = Temp
                    End If
                Next j
            Next i
        .Value = Trim(Join(X, ";"))
    End With
Next k
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,986
Messages
6,122,611
Members
449,090
Latest member
vivek chauhan

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