+ Reply to Thread
Results 1 to 3 of 3

Lookup using Variable Number of Characters

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Lookup using Variable Number of Characters

    I have a list of UK postcodes. How can I use these in a Lookup? The first half of the post code can have either 2, 3 or 4 characters, however the first and second part of the postcode are separated by a single space, which may help. For example I want to lookup the characters prior to the space in a table to locate the correct County.

    Example:

    B1 = Birmingham
    BA4 = Somerset
    BB10 = Lancashire

    My main table displays the full postcode, e.g. BB10 4AW. I want to be able to take all the characters before the space and use these as a lookup in a master table, which only lists the first 2, 3, or 4 characters against the relevant county, so if I take BB10 4AW, I need to be able to take BB10 as my lookup to return Lancashire, but use the same formaula to be able to identify B1 as Birmingham.

    I understand the basic lookup concept, but not how to go about using a variable number of characters to use as the lookup.

    Many thanks

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Lookup using Variable Number of Characters

    If, say, the code you're looking up is in A1, and your lookup table is in C1:D20:

    =VLOOKUP(LEFT(A1,FIND(" ",A1)-1),C1:D20,2,FALSE)

  3. #3
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Lookup using Variable Number of Characters

    Hi Andrew,

    Perfect, works like a dream...

    Many thanks

+ 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