Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
mphell0
 
Posts: n/a
Default Sorting 1st, 2nd, 3rd...


I have a list of streets that I want to put in ascending order. Some of
the streets are named 1st, 2nd etc and others are just names. When I do
a sort on the data it correctly puts the named streets in order but
numbered streets appear out of order

for example

10th
11th
1st
20th
21st
2nd
30th
31st
3rd
a
b
c

Is there an easy way to sort so that it recognizes 1st and 2nd... in
the correct order so that it would sort like this:

1st
2nd
3rd
10th
11th
etc.

Any help would be appreciated.


--
mphell0
------------------------------------------------------------------------
mphell0's Profile: http://www.excelforum.com/member.php...o&userid=30153
View this thread: http://www.excelforum.com/showthread...hreadid=507716

  #2   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default Sorting 1st, 2nd, 3rd...

On Thu, 2 Feb 2006 10:17:28 -0600, mphell0
wrote:


I have a list of streets that I want to put in ascending order. Some of
the streets are named 1st, 2nd etc and others are just names. When I do
a sort on the data it correctly puts the named streets in order but
numbered streets appear out of order

for example

10th
11th
1st
20th
21st
2nd
30th
31st
3rd
a
b
c

Is there an easy way to sort so that it recognizes 1st and 2nd... in
the correct order so that it would sort like this:

1st
2nd
3rd
10th
11th
etc.

Any help would be appreciated.


Use a "helper column" into which you extract only the numeric portion. Then
sort on that "helper column".

Assuming a maximum of three digits in the number portion, one formula that will
extract the digits is:

=LEFT(A1,MATCH(FALSE,ISNUMBER(-LEFT(A1,{1,2,3})),0)-1)

(If there could be more than three, just change the array constant
accordingly).

In later versions of Excel, there is an option to "sort anything that looks
like a number, as a number". Select that option. If that is not present, then
use this similar formula, which will converts the "text" number to a "real"
number:

=IF(ISNUMBER(-LEFT(A1,1)),--LEFT(A1,MATCH(
FALSE,ISNUMBER(-LEFT(A1,{1,2,3})),0)-1),"")



--ron
  #3   Report Post  
Posted to microsoft.public.excel.misc
mphell0
 
Posts: n/a
Default Sorting 1st, 2nd, 3rd...


Thanks Ron but I found an easy way to do it without using helper
columns.
Maybe this will help others in the future. In ToolsOptionsCustom
Lists
you can create a list of values and how you want them sorted. I put
in
1st, 2nd, 3rd etc. into this list. Then when I went to do my sort, in
the sort
menu there is a tab called "options" that allows you to select a custom
list to
define the sort order. This worked perfectly.


--
mphell0
------------------------------------------------------------------------
mphell0's Profile: http://www.excelforum.com/member.php...o&userid=30153
View this thread: http://www.excelforum.com/showthread...hreadid=507716

  #4   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default Sorting 1st, 2nd, 3rd...

On Thu, 2 Feb 2006 11:02:58 -0600, mphell0
wrote:


Thanks Ron but I found an easy way to do it without using helper
columns.
Maybe this will help others in the future. In ToolsOptionsCustom
Lists
you can create a list of values and how you want them sorted. I put
in
1st, 2nd, 3rd etc. into this list. Then when I went to do my sort, in
the sort
menu there is a tab called "options" that allows you to select a custom
list to
define the sort order. This worked perfectly.


I'm glad that worked for you. Of course, you need to have all the items in the
list, or it may not sort properly. Also, I'm not sure (you should check it if
it may be an issue), if custom lists are stored with the workbook. That could
be an issue if you move the workbook to another machine.
--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sorting non contiguous ranges gsh20 Excel Discussion (Misc queries) 1 September 8th 05 04:50 PM
Sorting 1, 1A, 2, 2A, 3, 4, 4A, 4B . . . agc1234 Excel Discussion (Misc queries) 6 May 26th 05 08:02 PM
sorting number in ascending order Janice Lee via OfficeKB.com Excel Discussion (Misc queries) 2 April 8th 05 10:31 PM
SORTING question Rebecca New Users to Excel 3 February 24th 05 05:35 PM
Adding a KeyID column for sorting Rebecca New Users to Excel 3 February 20th 05 07:09 PM


All times are GMT +1. The time now is 11:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"