Custom Sort Order

ToddK

Board Regular
Joined
Dec 20, 2002
Messages
67
I have data strings that look like this:
1Y, p.6
1Z, p.8
1AA, p.92
1AB, p.76

When I create a report that outputs these strings, it sorts them alphabetically, so that I get:

1A, p.1
1AA, p.92
1AB, p.76
1B, p.4
1C, p.8

I want to define a custom sort order to get the double-letters to sort after single letters.

Anyone help?
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Use a query instead directly using table as data source of your report (or just apply my suggestion if you are already using a query)

Add one more field into your query and make it first field in order. That field should be Len(Field1) (Field1 is the one you want to run sort) and select Ascending Order for sort in Query. Also set Ascending Order for Field1. Just be careful that new field should be located before the Field1 in Query.

This will basically sort field by lenght of the text and then by letters then it will be like:

1A, p.1
1B, p.4
1C, p.8
1AA, p.92
1AB, p.76

I hope this helps.

Regards
Suat

Edited : Used original sample data given in thread.
This message was edited by smozgur on 2002-12-24 06:51
 
Upvote 0

Forum statistics

Threads
1,221,497
Messages
6,160,152
Members
451,625
Latest member
sukhman

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