+ Reply to Thread
Results 1 to 7 of 7

Is it possible to do vlookup with criteria?

  1. #1
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Is it possible to do vlookup with criteria?

    Hi Everyone,

    Im not sure how to start this but i will start with my problem. I have two tables in one worksheet cointaning a couple of hundreds of account.

    One of the Table has the Operator Code with their Fullname whereas the other has their Initial only and No Operator Code. I want to copy the OP Code into the second table using vlookup but the problem is they will never match as the other table has initials and surname only. Is there anyway this can be done at all?

    I have attached a copy of the file.

    Many thanks in Advance.
    Attached Files Attached Files
    Last edited by NBVC; 09-29-2009 at 10:28 AM.

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

    Re: Is it possible to do vlookup with criteria?

    If you are as consistent as your samples show, then try:

    =INDEX($H$6:$H$14,MATCH(LEFT(D6)&"*"&MID(D6,4,100),$I$6:$I$14,0))

    copied down.
    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
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Is it possible to do vlookup with criteria?

    Or use this to extract the inital and surname

    =LEFT(I6,1)&RIGHT(I6,LEN(I6)-FIND(" ",I6)+1)

    to match column D

    What happens if there is a duplicate name, ie John Jones and Jenny Jones will both be listed as "J Jones"
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  4. #4
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Talking Re: Is it possible to do vlookup with criteria?

    Quote Originally Posted by NBVC View Post
    If you are as consistent as your samples show, then try:

    =INDEX($H$6:$H$14,MATCH(LEFT(D6)&"*"&MID(D6,4,100),$I$6:$I$14,0))

    copied down.

    @ NBVC

    Wow! you are amazing! I wish i have a brain like yours.

    Would you mind explaining the formula for me if you dont mind please!

    Thanks very much... you're a life saver!
    Last edited by crazysniper; 09-29-2009 at 10:21 AM.

  5. #5
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Is it possible to do vlookup with criteria?

    Quote Originally Posted by Special-K View Post
    Or use this to extract the inital and surname

    =LEFT(I6,1)&RIGHT(I6,LEN(I6)-FIND(" ",I6)+1)

    to match column D

    What happens if there is a duplicate name, ie John Jones and Jenny Jones will both be listed as "J Jones"
    I've tested your method too.. this would work as well as it will matched the names in table B to table A and then you can just do the vlookup from there. Awesome!

    Thanks as well for the input

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

    Re: Is it possible to do vlookup with criteria?

    Thanks... and you are welcome.

    Well Index/Match works somewhat like Vlookup and is more flexible.. i.e. unlike Vlookup, you can have the lookup column on either side of the extracting column... also, you can indicate column to extract from by either referencing the single column in the index part or referencing a table, and indicating column by number of by matching the column title, etc...

    So here we are indexing a column that is to the left of the actual lookup column.. so can't use Vlookup....

    Then to find the Matching row, we use non other than the obvious MATCH() function which finds the position within a single dimension array that a match is found... and that allows you to correspond the position to the indexed range to pull the right value...

    For matching, I used a wildcard between to know factors.. the Left(D6) simply extracts the Left-most character in the string.. the * means that you can have anything after that left character and the MID(D6,4,100) says the the part after the 4th character in D6 up to 100 characters must also match...

    so for example,

    MATCH(LEFT(D6)&"*"&MID(D6,4,100),$I$6:$I$14,0)

    take J from Jennifer Jones and matches only the J, followed by anything (including just a space) and must end with Jones... and finds it in I6:I14.. and returns the position number.. then throws that number to the indexed array of $H$6:$H$14 and returns the corresponding match

  7. #7
    Registered User
    Join Date
    08-28-2009
    Location
    London
    MS-Off Ver
    Excel 2003, 2007
    Posts
    80

    Re: Is it possible to do vlookup with criteria?

    Thats Superb!

    Again.. thank you very much @ NBVC

+ 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