MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Sort odd even address


Posted by Don McGee on June 14, 2000 3:10 PM

Desire to sort address by odd and even:

1 elm
2 elm
3 elm
4 elm
1 oak
2 oak
3 oak
4 oak

sort should end up as:

1 elm
3 elm
2 elm
4 elm
1 oak
3 oak
2 oak
4 oak

Thanks


Posted by mads on June 16, 0100 10:01 PM

Here's one way. Probably not the best way.
It is assumed that the addresses are in column A starting at A1.

1.Insert 2 columns before column A
2.Put in A1(and copy down) :- =IF(MOD(LEFT(C1,FIND(" ",C1)-1),2)=0,"even","odd").
3.Put in B1(and copy down) :- =RIGHT(C1,LEN(C1)-FIND(" ",C1,1))
4.Sort the data(by Column B then by Column A)
5.Delete Columns A & B

The above could be done by a macro.

mads