+ Reply to Thread
Results 1 to 2 of 2

UK Postcodes which sort correctly?

  1. #1
    Registered User
    Join Date
    11-26-2007
    Posts
    3

    Advanced Sorting (UK Postcodes which sort correctly?)

    Hello!

    If anyone can help me sort a list of post-codes in excel so that they go NE1 XXX, NE2 XXX, NE12 XXX, instead of NE1 XXX, NE12 XXX, NE2 XXX, I'd be very greatful!

    The UK postcode Schema can be found here: http://www.govtalk.gov.uk/gdsc/html/frames/PostCode.htm

    Why?

    Because adjacent postcodes are much closer together than say NE3 and NE33 and it would make my life much easier when driving between them.

    Any help is greatly appreciated.

    A starting point might be to replace NE3 with NE03 so that the sort can work properly, How would I make this conversion temporarily and how would I turn it back after the sort? - should I use a special character instead of o (zero) which has a lower sort value than 0 (zero) in the ascii/excel sort logic? - but this might be barking up the wrong tree and there may be a much easier way of doing this - Help!

    Thanks in advance.

    Dice :-)
    Last edited by diceman; 11-26-2007 at 07:52 PM.

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Hello Diceman,

    Assuming you have postcodes in column A from A1 down, and these have spaces between the two parts of the postcode then try this formula in B1 copied down to add a zero as you suggest

    =REPLACE(A1,FIND(" ",A1)-1,0,LEFT(0,ISERR(MID(A1,FIND(" ",A1)-2,1)+0)+0))

    Now select both columns and sort by column B, column A will now contain your sorted list of postcodes

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1