Sorting

S

Slim Slender

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?
 
D

Dave Peterson

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.
 
L

Luke M

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top