+ Reply to Thread
Results 1 to 13 of 13

Lookup for Code that Corresponds to Part of string of text in a Cell

  1. #1
    Registered User
    Join Date
    08-05-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010 for Mac
    Posts
    60

    Lookup for Code that Corresponds to Part of string of text in a Cell

    I am trying to find a function to lookup a code assigned with a string of text, e.g., connect that code 0851 corresponds with "Black Hat." The problem is that the table that I would normally use the vlookup for has multiple strings of text in the cell, so it won't find "Black Hat" since the cells go something like "Black Hat/Purple Shoes." Is there a function that will help me answer "If 'Black Hat' is contained in a cell, show me the code that corresponds to that cell which contains 'Black Hat'"?

    Hopefully that is clear. I was having trouble trying to figure out how I would ask. Basically, I am looking to see how I can identify a part of the text in a cell (almost like doing ctrl + F and typing in part of the word but still finding what you are looking for).

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    use wildcard
    something like
    vlookup("Blakc Hat"&"*",...

    or

    "*"&"Black Hat"&"*"
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  3. #3
    Registered User
    Join Date
    08-05-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010 for Mac
    Posts
    60

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    Yes, but the problem is that I am dealing with about 500 rows, all of which contain text in the cell. I would usually do VLOOKUP(A3, "Worksheet1" A4:F300, 3, FALSE), but A3 here is text, so A3= Black Hat, A4 = Yellow Shirt, A5 = Green Pants, A300 = Brown Shoes. I need something that looks at A3 and then finds the cell with "Black Hat/Hard Floor/etc etc" and it identifies that the cell contains Black Hat and returns the code in the cell related to it.

    Thanks!

  4. #4
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    did you tried it?

    =vlookup("*"&A3&"*",A4:F300, 3, FALSE)

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    Vlad's suggestion using a wild card should work
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Registered User
    Join Date
    08-05-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010 for Mac
    Posts
    60

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    It's giving me #N/A

  7. #7
    Registered User
    Join Date
    08-05-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010 for Mac
    Posts
    60

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    Update: The following function works for about 20% of the rows in my worksheet

    =VLOOKUP("*"&B230&"*",'Code Names'!$B$2:$C$58,2,FALSE)

    The problem is that if the cell in column B is, say, Program Assistant, it will show up as N/A because it won't find this in a cell that has "Program Director/Program Assistant", i.e., it won't find Program Assistant if it is the second, third, etc, in a cell. It only finds it if it is "Program Assistant/Program Director"

  8. #8
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    The formula works with me
    Attached Files Attached Files
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  9. #9
    Registered User
    Join Date
    08-05-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010 for Mac
    Posts
    60

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    It gives me a bunch of N/As. please see this workbook
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    That is correct; because in sheet2 I can't find anywhere 'Administrative Programs'

  11. #11
    Registered User
    Join Date
    08-05-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010 for Mac
    Posts
    60

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    Ok I think I'm almost there. I see what you are saying, so for example I want to find Paralegal code but the name is Paralegal Program, but only Paralegal is contained in the sheet with the corresponding code -- how do I modify the lookup value so that is only looks for "Paralegal" instead of requiring the cell to contain the full name "Paralegal program"?

  12. #12
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    I see another problem:

    If your are looking voor "management", what value you expect to get?
    sheet2 C33
    sheet2 C56
    sheet2 C57
    sheet2 C58

  13. #13
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Lookup for Code that Corresponds to Part of string of text in a Cell

    let's try it like this

    First use the whole string (i'm expecting a max word of 3)
    =VLOOKUP("*"&B230&"*",'Code Names'!$B$2:$C$58,2,FALSE) ->all string
    Second extract first two words
    =VLOOKUP("*"&LEFT(B230,FIND(" ",B230,FIND(" ",B230,1)+1)-1)&"*",'Code Names'!$B$2:$C$58,2,FALSE) -> look for two words
    Last get first word
    =VLOOKUP("*"&LEFT(B230,FIND(" ",B230)-1)&"*",'Code Names'!$B$2:$C$58,2,FALSE) -> use first word
    Then incorporate the 3 vlookup

    =Iferror(iferror(Iferror(VLOOKUP("*"&B230&"*",'Code Names'!$B$2:$C$58,2,FALSE),VLOOKUP("*"&LEFT(B230,FIND(" ",B230,FIND(" ",B230,1)+1)-1)&"*",'Code Names'!$B$2:$C$58,2,FALSE)),VLOOKUP("*"&LEFT(B230,FIND(" ",B230)-1)&"*",'Code Names'!$B$2:$C$58,2,FALSE)),"no match")

+ 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. [SOLVED] Cannot get a cell to retain formatting when a part of a text string
    By Grimace in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-17-2012, 12:08 AM
  2. Replies: 4
    Last Post: 07-12-2010, 08:04 PM
  3. Finding part of a text string in a cell
    By Tonro in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-18-2008, 05:59 PM
  4. removing part of text string to another cell
    By jamie_k in forum Excel General
    Replies: 2
    Last Post: 07-24-2006, 06:00 AM
  5. Replies: 3
    Last Post: 12-09-2005, 03:10 PM

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