+ Reply to Thread
Results 1 to 7 of 7

how to find string in a cell and display results

  1. #1
    Registered User
    Join Date
    07-23-2010
    Location
    ithaca ny
    MS-Off Ver
    Excel 2007
    Posts
    40

    how to find string in a cell and display results

    I'm working with product data and column a has product names and descriptions all lumped together. There is no pattern to the names or number of characters. How do i create a formula that looks in each column a cell for 1 of 5 character strings (looking for: "extra small", "small", "medium", "large", "extra large") and return in column b a set value determining which string is found ( if "extra small" return "XS", if "small" return "S", ...)

    I'm comfortable working with number formulas but am completely lost when working with text formulas. Please help point me in the right direction.

    thanks

  2. #2
    Valued Forum Contributor
    Join Date
    02-09-2012
    Location
    Mauritius
    MS-Off Ver
    Excel 2007
    Posts
    1,055

    Re: how to find string in a cell and display results

    Hello..
    Upload a sample file
    Click *, if my suggestion helps you. Have a good day!!

  3. #3
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: how to find string in a cell and display results

    There are a few ways to handle this, but it depends on what you want for a setup...

    One way...build a table and use =VLOOKUP(D1,$A$1:$B$5,2,0)

    Please Login or Register  to view this content.
    You could also use =LOOKUP(D1,A1:B5)

    but notice the list is sorted A-Z

    Please Login or Register  to view this content.
    or you could imbed the values...

    =LOOKUP(D1,{"Extra Large","XL";"Extra Small","XS";"Large","L";"Medium","M";"Small","S"})
    Last edited by jeffreybrown; 04-30-2012 at 12:22 PM.
    HTH
    Regards, Jeff

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how to find string in a cell and display results

    This is a fun one. First, create a "table" that lists the strings to search in the first column and the values to return in the second. It's important that the LONGER strings be at the bottom of this table... so "small" would be near the top and "extra small" (a longer version of "small") is below it.

    Let's create that table in columns I:J

    Please Login or Register  to view this content.
    Then, assuming the first string to find is in cell A1, this formula in B1:

    =LOOKUP(2, 1/(ISNUMBER(SEARCH($I$1:$I$5, A1))), $J$1:$J$5)



    EDIT: This is for pulling the "size" out of a longer text string, like The extra small shirt is blue. If the cell A1 really only holds the value "Small" or "extra small", then use the VLOOKUP suggested above.
    Last edited by JBeaucaire; 04-30-2012 at 12:21 PM.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: how to find string in a cell and display results

    Or, you could just use a lot of nested IF's like so. The "Extra" sizes need to be before the regular sizes

    Please Login or Register  to view this content.
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  6. #6
    Registered User
    Join Date
    07-23-2010
    Location
    ithaca ny
    MS-Off Ver
    Excel 2007
    Posts
    40

    Re: how to find string in a cell and display results

    thanks everyone for the suggetions. the values were nested inside other content in the same cell so i used the solution from JBeaucaire, worked great. I didnt even think to set up a lookup table for this, was originally thinking along the lines of nested ifs, as the last poster suggested.

    thanks again everyone.

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: how to find string in a cell and display results

    If that takes care of your need, please select Thread Tools from menu above and set this topic to SOLVED.

+ 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