+ Reply to Thread
Results 1 to 5 of 5

Formula to remove middle space in 8 figure postcodes

  1. #1
    Registered User
    Join Date
    05-14-2013
    Location
    Bath
    MS-Off Ver
    Excel 2010
    Posts
    2

    Formula to remove middle space in 8 figure postcodes

    Hi

    I have list of variable length postcodes eg BA1 1AA and BS11 2AA -I am looking for a formula that will remove the middle space in the longer postcode but not the shorter one, ie it will standardise both types to 7 characters long, so BS11 2AA becomes BS112AA, whilst BA1 1AA remains unchanged.

    I seem to recall seeing a formula which uses IF SUBSTITUTE which has worked before.

    Thanks

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Formula to remove middle space in 8 figure postcodes

    =if(len(a1)>7,substitute(a1," ",""),a1)
    Cheers
    Andy
    www.andypope.info

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Formula to remove middle space in 8 figure postcodes

    =if(len(a1)=7,a1,substitute(a1," ",""))
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  4. #4
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Formula to remove middle space in 8 figure postcodes

    hi David_Haycock, welcome to the forum. so your data only has 7 or 8 characters? try:
    =IF(LEN(A1)=7,A1,SUBSTITUTE(A1," ",""))

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  5. #5
    Registered User
    Join Date
    05-14-2013
    Location
    Bath
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Formula to remove middle space in 8 figure postcodes

    Thank you all for your submissions. Problem is now resolved.

    Kind regards

+ 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