+ Reply to Thread
Results 1 to 5 of 5

Thread: Postcode Extraction (=Right, =Left, = Middle not possible)

  1. #1
    Registered User
    Join Date
    01-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Question Postcode Extraction (=Right, =Left, = Middle not possible)

    Hi there,

    I have about 2000 address details from which I want to extract just the UK postcode.

    The number of characters (and spaces) before and after the postcode differs for each address so Left, Right, Mid or Len functions will not help.

    I imagine a formula that says the following would work however I am too much of a novice to know if this is possible!

    "If you find 2 consecutive capital letters followed by 1 number and a space extract the 7 characters from and including the 1st capital letter, if you find 2 consecutive capital letters followed by 2 numbers and a space extract the 8 characters from and including the 1st capital letter"

    Some example addresses are below

    Hope someone can help!

    Truro - Truro TR1 3XL; Treyew Road ; 01872 260881; 01872 260881; 1872 260881 ; ;
    Bodmin - Bodmin PL31 2SS; Dennison Road ; 01208 269 743; 01208 269 743; 1208 269 743 ; ;
    Plymouth - Plymouth PL1 1LE; The Armada Centre Armada Centre ; 01752 674767; 01752 674767; 1752 674767 ; ;
    Marsh Mills - Plymouth PL3 6RL; Plymouth Road Crabtree ; 01752 222748; 01752 222748; 1752 222748 ; ;
    Swansea - Swansea SA1 8JA; Quay Parade ; 01792 653985; 01792 653985; ;
    Barnstaple - Barnstaple EX31 3NH; Gratton Way Roundswell Buisness Park ; 01271 325498; 01271 325498; 1271 325498 ; ;

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: Postcode Extraction (=Right, =Left, = Middle not possible)

    One possibility if we assume post code always followed by ; (first instance) and that the post code will commence at point of 2nd space prior to ; then:

    =TRIM(RIGHT(SUBSTITUTE(LEFT(A1,FIND(";",A1)-1)," ",REPT(" ",LEN(A1))),2*LEN(A1)))
    copied down
    where A1 holds string
    Quote Originally Posted by TheZman
    If you find 2 consecutive capital letters followed by 1 number and a space extract the 7 characters from and including the 1st capital letter, if you find 2 consecutive capital letters followed by 2 numbers and a space extract the 8 characters from and including the 1st capital letter
    you could use RegExp patterns etc but I think the formula above should suffice (based on variety of examples provided)

  3. #3
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057

    Re: Postcode Extraction (=Right, =Left, = Middle not possible)

    Assuming the postcode is always 7 or 8 characters (with the space) try

    =TRIM(MID(A1,FIND(";",A1)-8,8))
    Audere est facere

  4. #4
    Registered User
    Join Date
    01-12-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Postcode Extraction (=Right, =Left, = Middle not possible)

    Both methods work - fantastic! Thank you both - much appreciated!

  5. #5
    Forum Guru Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    5,590

    Re: Postcode Extraction (=Right, =Left, = Middle not possible)

    And a variation on one Don posted earlier

    =TRIM(MID(A2,SEARCH("????????;",A2,1),8))

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0