#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Sorting numbers

I am trying to sort numbers from the left. Example would be that ALL the 1's
are at the top, the the 2's and so on ending with the 9's. No matter how long
the length is.
It is not sort smallest to largest or largest to smallest. It would look
something like this:
1
12
123
2
21
213
3
31
312
4
41
412


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,939
Default Sorting numbers

Probably the easiest will be to convert the numbers to text and then sort
that column.

In an adjacent column add the formula
=text(A1, "#")
and copy down

This creates a list of your numbers but stored as text. Sort this column. If
/ When asked how you would like it sorted select Numbers and text Seperately.
--
HTH...

Jim Thomlinson


"wavers3" wrote:

I am trying to sort numbers from the left. Example would be that ALL the 1's
are at the top, the the 2's and so on ending with the 9's. No matter how long
the length is.
It is not sort smallest to largest or largest to smallest. It would look
something like this:
1
12
123
2
21
213
3
31
312
4
41
412


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default Sorting numbers

The numbers must be text to sort as your example.

Run this macro on the column then sort.

Sub Add_Text()
Dim Cell As Range
Dim moretext As String
Dim thisrng As Range
Set thisrng = Selection
moretext = "'"
For Each Cell In thisrng
Cell.Value = moretext & Cell.Value
Next
End Sub

When you sort ascending you will be given two options.

1. Sort anything that looks like a number as a number.

2. Sort numbers and numbers stored as text separately.

Select option 2.


Gord Dibben MS Excel MVP

On Tue, 2 Jun 2009 13:51:00 -0700, wavers3
wrote:

I am trying to sort numbers from the left. Example would be that ALL the 1's
are at the top, the the 2's and so on ending with the 9's. No matter how long
the length is.
It is not sort smallest to largest or largest to smallest. It would look
something like this:
1
12
123
2
21
213
3
31
312
4
41
412


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 806
Default Sorting numbers

Hello,

I suggest to use my UDF GSort with String sort:
http://www.sulprobil.com/html/sort_vba.html

Regards,
Bernd
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3
Default Sorting numbers

Jim,

Thanks, that did what I needed it to do. Appreciate the help, from every one.

"Jim Thomlinson" wrote:

Probably the easiest will be to convert the numbers to text and then sort
that column.

In an adjacent column add the formula
=text(A1, "#")
and copy down

This creates a list of your numbers but stored as text. Sort this column. If
/ When asked how you would like it sorted select Numbers and text Seperately.
--
HTH...

Jim Thomlinson


"wavers3" wrote:

I am trying to sort numbers from the left. Example would be that ALL the 1's
are at the top, the the 2's and so on ending with the 9's. No matter how long
the length is.
It is not sort smallest to largest or largest to smallest. It would look
something like this:
1
12
123
2
21
213
3
31
312
4
41
412


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
How can I keep my numbers while sorting? New2Excell Excel Discussion (Misc queries) 1 November 20th 07 04:40 PM
Sorting high numbers from low numbers between two rows scotty New Users to Excel 7 February 12th 07 09:38 PM
Sorting - cells containing numbers, numbers and letters Gunny Excel Discussion (Misc queries) 5 July 16th 06 01:22 AM
Sorting numbers with differing numbers of digits Trudy Excel Discussion (Misc queries) 5 March 4th 06 12:31 PM
sorting the row by numbers Bubu Excel Worksheet Functions 0 January 12th 05 06:55 AM


All times are GMT +1. The time now is 05:20 PM.

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

About Us

"It's about Microsoft Excel"