+ Reply to Thread
Results 1 to 6 of 6

Formula to correct spacing in UK postcodes?

  1. #1
    Registered User
    Join Date
    06-02-2015
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    6

    Formula to correct spacing in UK postcodes?

    Hello all,

    I'd be so grateful if you could help me. I have thousands of UK post codes in one column. Most are formatted correctly but many are missing spaces. For any non-UK residents reading this, our post codes either have a 2 character, 3 character or 4 character prefix like this:

    A1 2BC
    AB1 2CD
    AB12 3CD

    However, I have a lot of records that are missing those spaces after the prefix, like this:

    A12BC
    AB123CD
    AB12CD

    Although the number of characters in the prefix vary, UK postcodes always end with 3 characters after the space.

    Is there any way of checking for a space before the last three characters, then adding a space if one isn't found? Or any other solutions you can think of?

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Formula to correct spacing in UK postcodes?

    A fairly simple =UPPER(TRIM(LEFT(A1, LEN(A1)-3)) & " " & RIGHT(A1, 3))

  3. #3
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formula to correct spacing in UK postcodes?

    Enter this formula in B1 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    RemoveSpaces.JPG
    Last edited by AlKey; 05-09-2016 at 11:01 AM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  4. #4
    Registered User
    Join Date
    06-02-2015
    Location
    London, England
    MS-Off Ver
    2013
    Posts
    6

    Re: Formula to correct spacing in UK postcodes?

    Thank you both so much for your help!

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,042

    Re: Formula to correct spacing in UK postcodes?

    Hi, welcome to the forum

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a relatively new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formula to correct spacing in UK postcodes?

    Here is another that will handle spaces and those without them

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    RemoveSpaces.JPG
    Last edited by AlKey; 05-09-2016 at 11:12 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Formula needed to sort postcodes by first couple of letters
    By s7v7n38 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-08-2014, 10:59 AM
  2. Replies: 15
    Last Post: 11-25-2014, 08:14 AM
  3. Formula to remove middle space in 8 figure postcodes
    By David_Haycock in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-14-2013, 10:03 AM
  4. [SOLVED] Formula Needed To Truncate Postcodes
    By Dom2066 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 12-27-2012, 03:03 AM
  5. & formula - spacing
    By superspurs in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-10-2009, 04:24 AM
  6. Lookup formula for postcodes?
    By DKerr in forum Excel General
    Replies: 2
    Last Post: 06-29-2009, 09:26 AM
  7. Rows Spacing, Column Spacing
    By Pukka83 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2008, 12:05 AM

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