ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sorting (https://www.excelbanter.com/excel-discussion-misc-queries/247558-sorting.html)

Slim Slender

Sorting
 
I think it's reasonable to want the following items sorted in the following
order:
170B
424
439A
628
731
735
D08
D15

and, in fact, that's how I need them. However, Excel insists on putting them
in this order, which is rather scrambled but somewhat logical:
424
628
731
735
170B
439A
D08
D15
It appears to be sorting numbers first and then anything that contains an
alpha (treating digits as letters). Is there a way to get the first sort
order?

Dave Peterson

Sorting
 
170b is not a number, it's text.

I would try to separate the data into 3 columns--alphabetic prefix, numeric base
and alphabetic suffix (the prefix and base could be ""). Then sort the data by
these 3 helper columns.

But the formulas in those helper columns would depend on what can be in the
original column of data.

Is it always a single alpha either at the left or right of the string--never
both, sometimes both?

You may want to post a description and a representative sample of data to get
the formulas right.

This assumes that it's @####@ or ####@ or @#####.

In B1:
=IF(ISNUMBER(A1),"",IF(ISNUMBER(-RIGHT(A1,1)),LEFT(A1,1),""))

in C1:
=IF(ISNUMBER(A1),A1,
IF(ISNUMBER(-RIGHT(A1,1)),--RIGHT(A1,LEN(A1)-1),--LEFT(A1,LEN(A1)-1)))

In D1:
=IF(ISNUMBER(A1),"",IF(ISNUMBER(-RIGHT(A1,1)),"",RIGHT(A1,1)))

And then drag down as far as the data goes.

Then sort A:D by column B, then C, then D.



Slim Slender wrote:

I think it's reasonable to want the following items sorted in the following
order:
170B
424
439A
628
731
735
D08
D15

and, in fact, that's how I need them. However, Excel insists on putting them
in this order, which is rather scrambled but somewhat logical:
424
628
731
735
170B
439A
D08
D15
It appears to be sorting numbers first and then anything that contains an
alpha (treating digits as letters). Is there a way to get the first sort
order?


--

Dave Peterson

Luke M

Sorting
 
You could use a helper column with the formula:

=LEFT(A2,3)

And then sort based on the helper column. BTW, you are correct, XL sorts
numbers first, then blanks and symbols, then text. see "Default sort orders"
under XL help for further detail.
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Slim Slender" wrote:

I think it's reasonable to want the following items sorted in the following
order:
170B
424
439A
628
731
735
D08
D15

and, in fact, that's how I need them. However, Excel insists on putting them
in this order, which is rather scrambled but somewhat logical:
424
628
731
735
170B
439A
D08
D15
It appears to be sorting numbers first and then anything that contains an
alpha (treating digits as letters). Is there a way to get the first sort
order?



All times are GMT +1. The time now is 08:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com