Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Junior Member
 
Posts: 1
Default Sort by placement value from left to right & adding trailing zeros for short

How can I create a sort with helper columns or some other methods to achieve the following?
I would like to sort by evaluating each placement value from left to right and place them in descending order as if they are all the same length of character string... I have tried many helper columns but can't sort exactly as needed.

I would like to turn this:

1200
1205
1210
1211
1215
1218
1225
1245
1060-5
114-0-01
114-5-01
115-3-01
116-3-02
116-5-02
117-0-02
117-5-02
120-3-01
120-5-01
121-0-01
121-5-01
1225-3
123-0-01
123-5-01
124-0-01
124-5-01




INTO THIS, once sorted:

1060-5
114-0-01
114-5-01
115-3-01
116-3-02
116-5-02
117-0-02
117-5-02
120-3-01
120-5-01
1200
1205
121-0-01
121-5-01
1210
1211
1215
1218
1225
1225-3
123-0-01
123-5-01
124-0-01
124-5-01
1245




Thank you!!!
  #2   Report Post  
Junior Member
 
Posts: 20
Default

Quote:
Originally Posted by MrTown View Post
How can I create a sort with helper columns or some other methods to achieve the following?
I would like to sort by evaluating each placement value from left to right and place them in descending order as if they are all the same length of character string... I have tried many helper columns but can't sort exactly as needed.

I would like to turn this:

1200
1205
1210
1211
1215
1218
1225
1245
1060-5
114-0-01
114-5-01
115-3-01
116-3-02
116-5-02
117-0-02
117-5-02
120-3-01
120-5-01
121-0-01
121-5-01
1225-3
123-0-01
123-5-01
124-0-01
124-5-01




INTO THIS, once sorted:

1060-5
114-0-01
114-5-01
115-3-01
116-3-02
116-5-02
117-0-02
117-5-02
120-3-01
120-5-01
1200
1205
121-0-01
121-5-01
1210
1211
1215
1218
1225
1225-3
123-0-01
123-5-01
124-0-01
124-5-01
1245




Thank you!!!

If you had a helper column and use the substitute(a1, "-", "*") formula to replace the "-" with "*" and then sort according to this column, this should do the job.

If it still gives you problems let us know
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2
Default Sort by placement value from left to right & adding trailingzeros for short

How about:
=CONCATENATE(SUBSTITUTE(A1,"-","~"),LEFT("~~~~~~~~",8-LEN(A1)))
What a mess, uh?
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 6
Default Sort by placement value from left to right & adding trailingzeros for short

On Saturday, April 6, 2013 9:29:11 AM UTC+13, MrTown wrote:
How can I create a sort with helper columns or some other methods to

achieve the following?

I would like to sort by evaluating each placement value from left to

right and place them in descending order as if they are all the same

length of character string... I have tried many helper columns but can't

sort exactly as needed.

Two problems. The first is that Excel (2007 anyway) seems to persist in separating out the numbers and putting 12 before 111. This can be fixed by putting a character at the front. The second problem is that there is something strange about the "-" symbol when Excel sorts. So replace it with something else like the "~" suggested.

Make the helper column something like ="x"&SUBSTITUTE(A1,"-","~")
  #5   Report Post  
Junior Member
 
Posts: 1
Default

Quote:
Originally Posted by View Post
On Saturday, April 6, 2013 9:29:11 AM UTC+13, MrTown wrote:
How can I create a sort with helper columns or some other methods to

achieve the following?

I would like to sort by evaluating each placement value from left to

right and place them in descending order as if they are all the same

length of character string... I have tried many helper columns but can't

sort exactly as needed.

Two problems. The first is that Excel (2007 anyway) seems to persist in separating out the numbers and putting 12 before 111. This can be fixed by putting a character at the front. The second problem is that there is something strange about the "-" symbol when Excel sorts. So replace it with something else like the "~" suggested.

Make the helper column something like ="x"&SUBSTITUTE(A1,"-","~")
Use the below given function to convert all the values to six digit numbers assuming the value is in column A, and then afterwards you can sort them

=CONCATENATE(SUBSTITUTE($A2,"-","")*1,VLOOKUP(6-LEN(SUBSTITUTE($A2,"-","")),$L$2:$M$4,2,0))*1

in this you have to create a table for vlookup eg in above formula $L$2:$M$4
here you would mention the number of trailing zeros to use to complete 6 digits (precede with a space filler)

1 '0
2 '00
0 '

I hope this works for you.
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
Trailing zeros Gatz Excel Worksheet Functions 5 April 30th 09 08:34 PM
Trailing Zeros aftamath77 Excel Discussion (Misc queries) 3 October 7th 08 07:40 PM
Keep numbers as entered with trailing zeros Allie Excel Discussion (Misc queries) 2 August 3rd 06 06:39 PM
Keep Trailing Zeros When Convert To Text Todd G Excel Discussion (Misc queries) 2 March 23rd 06 03:16 PM
Trailing zeros are dropping off mjd918 Excel Programming 0 October 18th 04 09:27 PM


All times are GMT +1. The time now is 09:28 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"