+ Reply to Thread
Results 1 to 6 of 6

Extract Post Code data from a free text field

  1. #1
    Registered User
    Join Date
    08-27-2004
    Posts
    40

    Extract Post Code data from a free text field

    Good Afternoon,

    Just to provide a little background, I receive from a client a txt file which contains information relating to stock. This file is then loaded in Excel so manual changes can be made.

    However, the field which identifies the location of the stock is a free text field, hence the format of the data entry can vary and I don't believe we can get this altered.. I need to be able to extract the UK post code from this field, which if this field was in a regular format would not be so bad, but the Post Code can be anywhere in this field. E.g.

    BA113R Example Site 1
    Example Site 2 BA60RR
    Example EX456RT Site 3

    Talking to a colleague he has suggested that as the Post Code is the only entry with numbers we try to get Excel to identify all of the characters which numerical values, remember them, and then copy with them the two characters either side i.e the whole post code.

    The problem therefore is how? My colleague can programme everything apart from formulas/macros in Excel so it's a great idea but I was hoping someone maybe able to give us a leg up in terms of achieving it.

    Thanks in advance.

    Darren

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

    Re: Extract Post Code data from a free text field

    some uk postcodes don't follow that format tho
    see
    http://en.wikipedia.org/wiki/Postcod...United_Kingdom
    "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

  3. #3
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Extract Post Code data from a free text field

    Hi DGillham
    try this UDF
    Please Login or Register  to view this content.
    Last edited by pike; 07-04-2010 at 09:07 AM. Reason: change pattern to ([a-z]{2}\d+([a-z]{2}|[a-z]))
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: Extract Post Code data from a free text field

    Didnt think it was that simple
    the pattern should be

    Please Login or Register  to view this content.

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

    Re: Extract Post Code data from a free text field

    as long as there are absolutely no other numbers eg site 1 !
    then this should cover it as long as the codes are separated by space
    it covers all the formats of post codes (i think) and allows for no spaces when there should be
    Attached Files Attached Files
    Last edited by martindwilson; 07-04-2010 at 10:33 AM.

  6. #6
    Registered User
    Join Date
    08-27-2004
    Posts
    40

    Re: Extract Post Code data from a free text field

    Thank you both ever so much - Monday morning at work seems good for once!!

    Best regards

    Darren

+ 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