Closed Thread
Results 1 to 12 of 12

Splitting a Postcode

  1. #1
    Registered User
    Join Date
    09-14-2006
    Posts
    7

    Splitting a Postcode

    Hi all,

    I have a worksheet that has a column with loads of postcodes (5000 altogther). I need to split these postcodes into their two parts - Now this wouldn't be a problem if they were all the same length I.E GU73BT can easily be split into GU7 3BT using Data->Text to columns.

    Some of the postcodes I am dealing with are in this format; N57QB, whilst others are GU145TR. The thing with UK postcodes is that the second part of the split must contain 3 characters I.E the 7QB and 5TR.

    I hope this makes sense and that there is some solution, what I ideally need to do is use the Text to columns function but inversley.....From the right to left!

    I would do this manually but as I said there are over 5000 rows!

    Thanks in advance

    Rich

  2. #2
    Registered User
    Join Date
    09-14-2006
    Posts
    40

    Lightbulb

    Have you tried using the MID function? Using the MID function allows you to extract a specified number of characters, beginning anywhere in the string you specify.

    If you can sort the data by country, u can easily modify the MID funtion to extract the right amount of characters for the job.

    Not sure if that's what you were getting at...

  3. #3
    Registered User
    Join Date
    11-18-2005
    Posts
    34

    Splitting Post Codes

    Assuming that your Post Code is in cell A1:

    For the 1st part your formula would be LEFT(A1,LEN(A1)-3)

    For the 2nd part your formula would be =RIGHT(A1,3)

  4. #4
    Registered User
    Join Date
    09-14-2006
    Posts
    7
    Quote Originally Posted by taylorm
    Assuming that your Post Code is in cell A1:

    For the 1st part your formula would be LEFT(A1,LEN(A1)-3)

    For the 2nd part your formula would be =RIGHT(A1,3)
    That's what I need!

    Thanks

  5. #5
    Registered User
    Join Date
    09-14-2006
    Posts
    7
    Right, there's a further complication now.....I need both parts of the postcode in one cell.....but with a space in between the two parts I.E. I need to join the GU7 from one cell to the 3BT in the other cell, but they need to have a space in between the two split parts......Hopefully that makes sense.

    I've had a go myself by messing around with the formula but I can;t figure anything out.

    Thanks

  6. #6
    Forum Expert oldchippy's Avatar
    Join Date
    02-14-2005
    Location
    Worcester, UK
    MS-Off Ver
    Excel 2007 (Home)
    Posts
    7,097

    Thumbs up

    Quote Originally Posted by clarkerm
    Right, there's a further complication now.....I need both parts of the postcode in one cell.....but with a space in between the two parts I.E. I need to join the GU7 from one cell to the 3BT in the other cell, but they need to have a space in between the two split parts......Hopefully that makes sense.

    I've had a go myself by messing around with the formula but I can;t figure anything out.

    Thanks
    =A1&" "&B1

    oldchippy

  7. #7
    Forum Contributor
    Join Date
    05-03-2004
    Location
    England
    MS-Off Ver
    2003 Excel
    Posts
    118
    or you could replace the previous formula with this one

    =LEFT(A1,LEN(A1)-3)&" "&RIGHT(A1,3)
    Greg.

    "The most overlooked advantage of owning a computer is that if they foul up there's no law against whacking them around a bit."

  8. #8
    Registered User
    Join Date
    09-14-2006
    Posts
    7
    Brilliant! I owe you guys lol

  9. #9
    Registered User
    Join Date
    04-16-2021
    Location
    Scotland
    MS-Off Ver
    365
    Posts
    1

    Re: Splitting a Postcode

    Another way to tackle this problem is to locate/find the space " " in between both halves of the post code and then insert it into a LEFT formula. E.g =find(" ",A1) for Post code EH11 4RT will return a value of 5 as the space " " is charachters in from the left. If you then subtract 1 you get the last letter of the first part of the post code e.g. =FIND(" ",A1)-1. If you then insert this into a LEFT formula =LEFT(A1,(FIND(" ",A1)-1))

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2504
    Posts
    13,741

    Re: Splitting a Postcode

    Another way.


    A
    B
    C
    1
    GU73BT
    GU7 3BT
    =REPLACE(A1,LEN(A1)-2,0," ")
    2
    N57QB
    N5 7QB
    Dave

  11. #11
    Registered User
    Join Date
    02-09-2023
    Location
    London, England
    MS-Off Ver
    O365
    Posts
    10
    Quote Originally Posted by FlameRetired View Post
    Another way.


    A
    B
    C
    1
    GU73BT
    GU7 3BT
    =REPLACE(A1,LEN(A1)-2,0," ")
    2
    N57QB
    N5 7QB
    How do you avoid getting two spaces if you have some postcodes that already have a space? (If you’re trying to tidy a whole sheet of postcodes)

    Thanks

  12. #12
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,738

    Re: Splitting a Postcode

    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original.

    Please see Forum Rule #4 about hijacking and start a new thread for your query.

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

Closed 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