Sorting Alphanumeric Data - Please Help!

val_rucarean

New Member
Joined
May 1, 2014
Messages
3
Hi guys.

I have this output in column A after the standard A to Z sort:

LFL388C10SUN
LFL388C11SUN
LFL388C12SUN
LFL388C13SUN
LFL388C14SUN
LFL388C1SUN
LFL388C2SUN
LFL388C3SUN
LFL388C4SUN
LFL388C5SUN
PL22C10OPT
PL22C11OPT
PL22C12OPT
PL22C1OPT
PL22C2OPT
PL22C3OPT

<colgroup><col></colgroup><tbody>
</tbody>

<colgroup><col></colgroup><tbody>
</tbody>

<colgroup><col></colgroup><tbody>
</tbody>

However the output I would like is:

LFL388C1SUN
LFL388C2SUN
LFL388C3SUN
LFL388C4SUN
LFL388C5SUN

<tbody>
</tbody>
LFL388C10SUN
LFL388C11SUN
LFL388C12SUN
LFL388C13SUN
LFL388C14SUN
PL22C1OPT
PL22C2OPT
PL22C3OPT
PL22C10OPT
PL22C11OPT
PL22C12OPT

<tbody>
</tbody>

<tbody>
</tbody>

<colgroup><col></colgroup><tbody>
</tbody>

The problem really is how to get Excel to sort the number after the "C" properly. I'm happy to get rid of "SUN" and "OPT" prior to sorting if that makes it easier.

Any help will be greatly appreciated.

Thanks
Val
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Insert a Helper column
with this formula
=LEFT(A1,FIND("C",A1)-1)&MID(SUBSTITUTE(SUBSTITUTE(A1,"SUN",""),"OPT",""),FIND("C",A1)+1,LEN(A1)-FIND("C",A1)+1)
and sort on that column

UPDATE: Forget that, it wont work properly
 
Upvote 0
Try this

Add 2 Helper columns
with data in column A

in column B
=LEFT(A1,FIND("C",A1)-1)
in column C
=MID(SUBSTITUTE(SUBSTITUTE(A1,"SUN",""),"OPT",""),FIND("C",A1)+1,LEN(A1)-FIND("C",A1)+1)

Sort on column B then on column C
 
Upvote 0
Try this

Add 2 Helper columns
with data in column A

in column B
=LEFT(A1,FIND("C",A1)-1)
in column C
=MID(SUBSTITUTE(SUBSTITUTE(A1,"SUN",""),"OPT",""),FIND("C",A1)+1,LEN(A1)-FIND("C",A1)+1)

Sort on column B then on column C

Hi Special-K99,

This works great for sorting the number after the "C" and I thank you for that but (silly enough) I failed to mention the first group of digits (column B) is equally important to sort correctly, any chance this can be fixed? You will see below that "LFL388" sits in between "LFL38" and "LFL71". Can your formula be improved to correct this?

ABC
LFL38C1SUNLFL381
LFL38C2SUNLFL382
LFL38C14SUNLFL3814
LFL388C1SUNLFL3881
LFL388C2SUNLFL3882
LFL388C3SUNLFL3883
LFL388C4SUNLFL3884
LFL388C5SUNLFL3885
LFL388C10SUN LFL38810
LFL388C11SUNLFL38811
LFL388C12SUNLFL38812
LFL388C13SUNLFL38813
LFL388C14SUNLFL38814
LFL71C2SUNLFL712
PL22C1OPT
PL221
PL22C2OPTPL222
PL22C3OPTPL223
PL22C10OPT
PL2210
PL22C11OPTPL2211
PL22C12OPTPL2212

<colgroup><col><col><col></colgroup><tbody>
</tbody>

Many thanks
Val
 
Upvote 0

Forum statistics

Threads
1,203,060
Messages
6,053,305
Members
444,651
Latest member
markkuznetsov1

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