+ Reply to Thread
Results 1 to 11 of 11

Vlookup based on "contains"? Is this possible?

  1. #1
    Registered User
    Join Date
    05-23-2012
    Location
    Phx, AZ
    MS-Off Ver
    Excel 2007
    Posts
    16

    Vlookup based on "contains"? Is this possible?

    Hi, I am looking for a formula that will run like a vlookup, but will look for a "contains" match rather than an exact "match". I need a formula that will grab the "base part plus ending" from list 1 and go search for the base part in List 2 and return the base part as the result.

    List 1: Base numbers plus endings
    List 2: Base numbers
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Vlookup based on "contains"? Is this possible?

    Are all base part number 13 characters long?
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Vlookup based on "contains"? Is this possible?

    How about this in the Base + Ending sheet, B2 and filled down.

    =LEFT(A2,13)

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Vlookup based on "contains"? Is this possible?

    In the examples, it's just the first 13 characters of the part number -- you don't need a lookup.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    05-23-2012
    Location
    Phx, AZ
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Vlookup based on "contains"? Is this possible?

    No, unfortunately there is no set character count for the base part. I was thinking that a "contains" formula may work, but I don't know if there is one.

    To explain more: There are an untold mixture of base part numbers. If the base part number exists within the "base part + ending", I need to understand what that base part is.
    Last edited by Echo_711; 07-14-2014 at 10:18 AM.

  6. #6
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Vlookup based on "contains"? Is this possible?

    If you can sort the Base Table in ascending order, then try

    =LOOKUP(A2,Base!$A$2:$A$9)

  7. #7
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Vlookup based on "contains"? Is this possible?

    Or use a small UDF:
    Please Login or Register  to view this content.

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

  8. #8
    Registered User
    Join Date
    05-23-2012
    Location
    Phx, AZ
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Vlookup based on "contains"? Is this possible?

    Olly, You got it! That's it!

    Jonmo1, yours returned results that I could not determin.

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Vlookup based on "contains"? Is this possible?

    Quote Originally Posted by Echo_711 View Post
    Jonmo1, yours returned results that I could not determin.
    Did you sort the table on the Base page in Ascending Order?

    Or are there sometimes no matching part # ?
    In that case, the lookup would return incorrect results.

    Try
    =IFERROR(LOOKUP(2^15,SEARCH(Base!$A$2:$A$9,A2),Base!$A$2:$A$9),"")

    Note, there cannot be any blanks in Base!$A$2:$A$9

  10. #10
    Registered User
    Join Date
    05-23-2012
    Location
    Phx, AZ
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Vlookup based on "contains"? Is this possible?

    Jonmo1! That's it also!!

    Yes, there are sometimes with no matching part #'s and yes I did sort ascending.

    This is great and works perfect as the UDF.

  11. #11
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: Vlookup based on "contains"? Is this possible?

    You're welcome.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 11-17-2013, 12:05 PM
  2. [SOLVED] How to USE """"" cells count """"" change font color
    By austin123456 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2013, 06:14 AM
  3. Replies: 5
    Last Post: 09-19-2008, 04:02 PM
  4. Replies: 0
    Last Post: 07-17-2006, 09:45 AM
  5. [SOLVED] IF(VLOOKUP("MYDATA", MYNAME, 4) = 0, "TRUE", "FALSE")
    By Souris in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-17-2005, 01:05 AM

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