+ Reply to Thread
Results 1 to 3 of 3

vlookup only looking at certain characters

  1. #1
    Registered User
    Join Date
    06-26-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    33

    vlookup only looking at certain characters

    Hi,

    I have 2 sheets in my workbook with codes in them. One is a master code list that has codes and their respective stock values, and I need to pull the values for certain codes onto my other sheet. It would work fine with a standard vlookup BUT....
    The master code list has slight variations in the codes that I need to ignore in the vlookup.
    For example, master list has a code 11112211 but my list has the code 11113311 - these both refer to the same item so I need the stock value for it. The numbers are all different every time, but it's always the 5th and 6th characters that need igoring.

    I need the formula to look at the first four AND last two characters, ignoring the middle two but ONLY if the code is 8 digits long. I have no idea what the best way to build this is and I've never used INDEX / MATCH functions but am willing to do so if it's the best way to achieve the results I need.

    I did consider having a couple of helper columns where I copy the first four and last two digits and then combine them and use this for the lookup, but I'd have to do that on my master list and the list I need to populate and I think it'll get really messy - I have about 3000 rows of data.

    I'm hoping an expert here can help me!!

    L

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: vlookup only looking at certain characters

    If you can make the first column of the lookup table TEXT through DATA/TEXT to COLUMNs, skipping to 3rd window and selecting TEXT from Column data Format area.....

    then try:

    =VLOOKUP(IF(LEN(A1)=8,REPLACE(A1,5,2,"??"),A1),I:J,2,0)

    where A1 is the lookup value and I:J is your lookup table.... adjust as necessary.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: vlookup only looking at certain characters

    Hi Lanos,

    You can use below formula to extract the common :-

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


    In case of any issue, upload a sample workbook.. thx


    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

+ 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.6.0 RC 1