#1   Report Post  
MXC
 
Posts: n/a
Default how do i sort?

I have a set of data with multiple columns (4). I need to sort my data by
one of the columns which contains both numbers and alpha-numeric
characters---but the cells are formatted as "Text". When I do a sort,
Excel's default is to sort from left to right and it puts all of my numbers
at the top with the alpha-numeric entries at the bottom. Is there a way that
I can sort my data so it doesn't do this? Example below:

Column to be sorted:
110
115
110LEG
115SAP
120
117LEG
117

When using Excel's Sort function it comes out like this:
110
115
117
120
110LEG
115SAP
117LEG

  #2   Report Post  
Gary Brown
 
Posts: n/a
Default

You've shown us how it looks and how you DON'T want it to look. How do you
WANT it to look?

"MXC" wrote:

I have a set of data with multiple columns (4). I need to sort my data by
one of the columns which contains both numbers and alpha-numeric
characters---but the cells are formatted as "Text". When I do a sort,
Excel's default is to sort from left to right and it puts all of my numbers
at the top with the alpha-numeric entries at the bottom. Is there a way that
I can sort my data so it doesn't do this? Example below:

Column to be sorted:
110
115
110LEG
115SAP
120
117LEG
117

When using Excel's Sort function it comes out like this:
110
115
117
120
110LEG
115SAP
117LEG

  #3   Report Post  
Max
 
Posts: n/a
Default

One guess and a quick play to try ..

Assuming the sample data is in col A, A1 down
and is representative (i.e. 3 numerics before the alphas)

Put in B1: =LEFT(TRIM(A1),3)
Copy B1 down

Now select cols A and B,
do a Data Sort (Sort by *col B*) Ascending OK

You'll get the desired? sort order in col A:

110
110LEG
115
115SAP
117LEG
117
120

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"MXC" wrote in message
...
I have a set of data with multiple columns (4). I need to sort my data by
one of the columns which contains both numbers and alpha-numeric
characters---but the cells are formatted as "Text". When I do a sort,
Excel's default is to sort from left to right and it puts all of my

numbers
at the top with the alpha-numeric entries at the bottom. Is there a way

that
I can sort my data so it doesn't do this? Example below:

Column to be sorted:
110
115
110LEG
115SAP
120
117LEG
117

When using Excel's Sort function it comes out like this:
110
115
117
120
110LEG
115SAP
117LEG



  #4   Report Post  
MXC
 
Posts: n/a
Default

The desired output in this example would be:
110
110LEG
115
115SAP
117
117LEG
120

"Gary Brown" wrote:

You've shown us how it looks and how you DON'T want it to look. How do you
WANT it to look?

"MXC" wrote:

I have a set of data with multiple columns (4). I need to sort my data by
one of the columns which contains both numbers and alpha-numeric
characters---but the cells are formatted as "Text". When I do a sort,
Excel's default is to sort from left to right and it puts all of my numbers
at the top with the alpha-numeric entries at the bottom. Is there a way that
I can sort my data so it doesn't do this? Example below:

Column to be sorted:
110
115
110LEG
115SAP
120
117LEG
117

When using Excel's Sort function it comes out like this:
110
115
117
120
110LEG
115SAP
117LEG

  #5   Report Post  
Max
 
Posts: n/a
Default

One way to try
(a revision to the formula in my earlier response
to you in the other branch)

Assuming the sample data is in col A, A1 down
and is representative (i.e. 3 numerics before the alphas)

Put in B1:

=IF(A1="","",IF(LEN(A1)=3,A1,LEFT(TRIM(A1),3)+ROW( )/10^10))

Copy B1 down

Now select cols A and B,
do a Data Sort (Sort by *column B*) Ascending OK

You'll get the desired sort order in col A:

110
110LEG
115
115SAP
117
117LEG
120
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"MXC" wrote in message
...
The desired output in this example would be:
110
110LEG
115
115SAP
117
117LEG
120





  #6   Report Post  
Max
 
Posts: n/a
Default

Put in B1:
=IF(A1="","",IF(LEN(A1)=3,A1,LEFT(TRIM(A1),3)+ROW( )/10^10))
Copy B1 down


Just an add-on. With the above formula in col B, instead of doing Data
Sort, think we could also drive out the same sort order by putting in say,
C1:

=IF(ISERROR(SMALL(B:B,ROWS($A$1:A1))),"",INDEX(A:A ,MATCH(SMALL(B:B,ROWS($A$1
:A1)),B:B,0)))

and copying C1 down
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----


  #7   Report Post  
MXC
 
Posts: n/a
Default

Thanks Max. One thing I forgot to mention was that my data set contains more
than 1 column (about 12 columns) and I am trying to sort the data by the
column with the alpha-numeric data as in my example.

"Max" wrote:

Put in B1:
=IF(A1="","",IF(LEN(A1)=3,A1,LEFT(TRIM(A1),3)+ROW( )/10^10))
Copy B1 down


Just an add-on. With the above formula in col B, instead of doing Data
Sort, think we could also drive out the same sort order by putting in say,
C1:

=IF(ISERROR(SMALL(B:B,ROWS($A$1:A1))),"",INDEX(A:A ,MATCH(SMALL(B:B,ROWS($A$1
:A1)),B:B,0)))

and copying C1 down
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----



  #8   Report Post  
MXC
 
Posts: n/a
Default

Thanks Max! Works perfect---even with multiple columns of data.

"Max" wrote:

One guess and a quick play to try ..

Assuming the sample data is in col A, A1 down
and is representative (i.e. 3 numerics before the alphas)

Put in B1: =LEFT(TRIM(A1),3)
Copy B1 down

Now select cols A and B,
do a Data Sort (Sort by *col B*) Ascending OK

You'll get the desired? sort order in col A:

110
110LEG
115
115SAP
117LEG
117
120

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"MXC" wrote in message
...
I have a set of data with multiple columns (4). I need to sort my data by
one of the columns which contains both numbers and alpha-numeric
characters---but the cells are formatted as "Text". When I do a sort,
Excel's default is to sort from left to right and it puts all of my

numbers
at the top with the alpha-numeric entries at the bottom. Is there a way

that
I can sort my data so it doesn't do this? Example below:

Column to be sorted:
110
115
110LEG
115SAP
120
117LEG
117

When using Excel's Sort function it comes out like this:
110
115
117
120
110LEG
115SAP
117LEG




  #9   Report Post  
Max
 
Posts: n/a
Default

Glad it worked !
Thanks for the feedback ..
--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"MXC" wrote in message
...
Thanks Max! Works perfect---even with multiple columns of data.



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 do I sort by row instead of by column? PercivalMound Excel Worksheet Functions 7 August 28th 06 10:41 PM
"-" ignored in sort Mike H Excel Discussion (Misc queries) 8 January 2nd 05 07:48 AM
Excel Sort function should not sort the cell formatting! Lisa D.N.1 Excel Worksheet Functions 1 December 28th 04 08:37 PM
Keeping Row 1 at the top during a Data Sort... bro. Billy Excel Worksheet Functions 2 December 13th 04 06:43 AM
Data > Sort function amnesia? Dave D Excel Discussion (Misc queries) 1 November 29th 04 10:44 PM


All times are GMT +1. The time now is 10:10 AM.

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"