Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Sorting problem, need some help

I'm trying to sort a text field that has both numbers and alphas in it, I am
not able to get it to sort right at all. Listed is how it is sorting followed
by how it needs to be. Any help would be appreciated.

This is how it is sorting:
1002086-A
1002-G
1003923-FB
1003-A
1003-G
1005243-01
1005-G
20-A

I need it to sort:
20-A
1002-G
1003-A
1003-G
1005-G
1002086-A
1003923-FB
1005243-01
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Sorting problem, need some help

I think in this case "helper" columns are in order

With
A1:A8 containing your posted data

Then
B1: =LEFT(A1,FIND("-",A1)-1)
C1: =SUBSTITUTE(A1,B1&"-","")

Copy those formula down through Row_8

Select A1:C8
From the Excel main menu:
<data<sort
Col_B: Ascending
Col_C: Ascending
At the option screens: Treat anything that looks like a number as a number

click the [OK] button

Then just delete the Col_B and Col_C formulas

Alternatively:
You could use a "one formula"approach
B1: ==REPT("0",8-FIND("-",A1))&A1

Then just sort on Columns A and B

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Chris B" wrote:

I'm trying to sort a text field that has both numbers and alphas in it, I am
not able to get it to sort right at all. Listed is how it is sorting followed
by how it needs to be. Any help would be appreciated.

This is how it is sorting:
1002086-A
1002-G
1003923-FB
1003-A
1003-G
1005243-01
1005-G
20-A

I need it to sort:
20-A
1002-G
1003-A
1003-G
1005-G
1002086-A
1003923-FB
1005243-01

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11
Default Sorting problem, need some help

I will try that, thank you

"Ron Coderre" wrote:

I think in this case "helper" columns are in order

With
A1:A8 containing your posted data

Then
B1: =LEFT(A1,FIND("-",A1)-1)
C1: =SUBSTITUTE(A1,B1&"-","")

Copy those formula down through Row_8

Select A1:C8
From the Excel main menu:
<data<sort
Col_B: Ascending
Col_C: Ascending
At the option screens: Treat anything that looks like a number as a number

click the [OK] button

Then just delete the Col_B and Col_C formulas

Alternatively:
You could use a "one formula"approach
B1: ==REPT("0",8-FIND("-",A1))&A1

Then just sort on Columns A and B

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Chris B" wrote:

I'm trying to sort a text field that has both numbers and alphas in it, I am
not able to get it to sort right at all. Listed is how it is sorting followed
by how it needs to be. Any help would be appreciated.

This is how it is sorting:
1002086-A
1002-G
1003923-FB
1003-A
1003-G
1005243-01
1005-G
20-A

I need it to sort:
20-A
1002-G
1003-A
1003-G
1005-G
1002086-A
1003923-FB
1005243-01

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,118
Default Sorting problem, need some help

typo:
in this formula
B1: ==REPT("0",8-FIND("-",A1))&A1

Should be only 1 equal sign
B1: =REPT("0",8-FIND("-",A1))&A1

(sorry about the typo....hopefully it was obvious)

***********
Regards,
Ron

XL2002, WinXP


"Chris B" wrote:

I will try that, thank you

"Ron Coderre" wrote:

I think in this case "helper" columns are in order

With
A1:A8 containing your posted data

Then
B1: =LEFT(A1,FIND("-",A1)-1)
C1: =SUBSTITUTE(A1,B1&"-","")

Copy those formula down through Row_8

Select A1:C8
From the Excel main menu:
<data<sort
Col_B: Ascending
Col_C: Ascending
At the option screens: Treat anything that looks like a number as a number

click the [OK] button

Then just delete the Col_B and Col_C formulas

Alternatively:
You could use a "one formula"approach
B1: ==REPT("0",8-FIND("-",A1))&A1

Then just sort on Columns A and B

Does that help?
***********
Regards,
Ron

XL2002, WinXP


"Chris B" wrote:

I'm trying to sort a text field that has both numbers and alphas in it, I am
not able to get it to sort right at all. Listed is how it is sorting followed
by how it needs to be. Any help would be appreciated.

This is how it is sorting:
1002086-A
1002-G
1003923-FB
1003-A
1003-G
1005243-01
1005-G
20-A

I need it to sort:
20-A
1002-G
1003-A
1003-G
1005-G
1002086-A
1003923-FB
1005243-01

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3,718
Default Sorting problem, need some help

Assuming your data in A1:A8
create dummy column B and column C

In B1 =--LEFT(A1,FIND("-",A1)-1)
In C1 =RIGHT(A1,LEN(A1)-FIND("-",A1))

Data Sort Sort by select Column B Ascending Then by Column C Ascending





"Chris B" wrote:

I'm trying to sort a text field that has both numbers and alphas in it, I am
not able to get it to sort right at all. Listed is how it is sorting followed
by how it needs to be. Any help would be appreciated.

This is how it is sorting:
1002086-A
1002-G
1003923-FB
1003-A
1003-G
1005243-01
1005-G
20-A

I need it to sort:
20-A
1002-G
1003-A
1003-G
1005-G
1002086-A
1003923-FB
1005243-01

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
Column matching - sorting. Fairly hard problem, I think. A S-D Excel Discussion (Misc queries) 13 April 7th 06 01:52 PM
Problem sorting cells containing hyperlinks cottonchipper Excel Worksheet Functions 1 November 5th 05 03:08 PM
Date sorting problem Ardell Excel Discussion (Misc queries) 1 November 4th 05 05:46 PM
An instant sorting problem Chris Excel Worksheet Functions 1 November 4th 04 07:31 PM
Sorting problem Chris Excel Worksheet Functions 1 November 3rd 04 11:27 PM


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