how can i sort on a perticular column for odd and even numbers

P

pushkarbhatkoti

Column1
0021D8B9B5FE
0021D8B9B494
001FCAE8A6B1
0021D8B9B6BF
001FCAE88DEE
0021D8B9AD96
001FCAE8A9C8
0021D8B9B5F7
0021D8B9B90E
0021D8B9B758


I want to sort on the last digit on each value:

for example:
0021D8B9B5FE
If last digit start with 1,3,5,7,9,a,c,e (consider this odd numbers)
if last digit start with 2,4,6,8,0, b,d (sondifer this even)


So how can I sort each raw based on the last character being odd or
even in excel.

=thanks in advance
 
O

OssieMac

Am I correct in assuming that you want all the odd last digits plus A,C,E etc
to be at the top of the sort and all the even last digits numbers plus B,D,F
to be at the bottom?

If my assumption is right then you need to use another column and get the
code for the last digit and if it is an even code then add 50 and if odd
leave code as it.

Then sort on the new column and the odd ones will be at the top and the even
at the bottom. The below example assumes that the number is in cell A2. Copy
the formula into B2 and copy it down to the bottom and sort on column B.

Note that the ASCII codes for odd numbers are all odd numbers also and code
for A is also odd. Therefore the Mod test is testing for even ASCII numbers
and if even then add 50. (Adding 50 takes them all above the ASCII codes for
uppercase alphas). Also the ASCII codes for numerics are lower than for alpha
characters so the numerics will be before the alphas.

The UPPER function is used in case there are any lower case alphas. Can be
left there whether or not you have lower case alphas.

The following is one line although it breaks on this post.

=IF(MOD(CODE(UPPER(RIGHT(A2,1))),2)=0,CODE(UPPER(RIGHT(A2,1)))+50,CODE(UPPER(RIGHT(A2,1))))
 
T

Teethless mama

Assume your data in A2:A11
Create a helper column
In B2: =CODE(RIGHT(A2))
copy down to B11

Prior to XL-2007 use this formula:
In C2:
=IF(ISERR(MATCH(SMALL(IF(MOD($B$2:$B$11,2)=1,$B$2:$B$11),ROWS($1:1)),$B$2:$B$11,0)),"",INDEX($A$2:$A$11,MATCH(SMALL(IF(MOD($B$2:$B$11,2)=1,$B$2:$B$11),ROWS($1:1)),$B$2:$B$11,0)))

ctrl+shift+enter, not just enter
Copy down to C11


XL-2007 use this formula:
In C2:
=IFERROR(INDEX($A$2:$A$11,MATCH(SMALL(IF(MOD($B$2:$B$11,2)=1,$B$2:$B$11),ROWS($1:1)),$B$2:$B$11,0)),"")

ctrl+shift+enter, not just enter
Copy down to C11
 
S

Shane Devenshire

Hi,

Enter the following formula and sort on its column:

=CODE(RIGHT(A2))+ISEVEN(CODE(RIGHT(A2)))*100

If this helps, please click the Yes button

Cheers,
Shane Devenshire
 

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