+ Reply to Thread
Results 1 to 15 of 15

specific text in a cell should return a text in another cell

  1. #1
    Registered User
    Join Date
    09-28-2016
    Location
    sydney
    MS-Off Ver
    13
    Posts
    8

    specific text in a cell should return a text in another cell

    Need a Formula/ vlook up that detects a specific text in a cell and result in a specific name in another cell
    A1B1-S1C1 contained in a cell should result in “Stage 1” in another cell (Detecting S1)
    A1B1-S2C1 contained in a cell should result in “Stage 2” in another cell (Detecting S2)

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,383

    Re: specific text in a cell should return a text in another cell

    Hi there. You can use this:
    =IF(ISNUMBER(SEARCH("S1",A1)),"Stage 1",IF(ISNUMBER(SEARCH("S2",A1)),"Stage 2",""))
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  3. #3
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2021
    Posts
    5,967

    Re: specific text in a cell should return a text in another cell

    Or ...

    =LOOKUP(2,1/SEARCH({"*","*S1*","*S2*"},A1&" "),{"","Stage 1","Stage 2"})

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: specific text in a cell should return a text in another cell

    Formula in B1 and copied down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    v A B
    1 A1B1-S1C1 Stage 1
    2 A1B1-S2C1 Stage 2
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: specific text in a cell should return a text in another cell

    Here's another one...

    =IF(COUNTIF(A2,"*S1*"),"Stage 1",IF(COUNTIF(A2,"*S2*"),"Stage 2",""))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Registered User
    Join Date
    09-28-2016
    Location
    sydney
    MS-Off Ver
    13
    Posts
    8

    Re: specific text in a cell should return a text in another cell

    Hi Glenn

    Your tip i works very well. Thank you.

    But I have one question: If my cells for search is very large, each having different specific text to search, then I have to keep on adding several IF(ISNUMBER(SEARCH("S2",A1)),"Stage 2",....

    please advise

  7. #7
    Registered User
    Join Date
    09-28-2016
    Location
    sydney
    MS-Off Ver
    13
    Posts
    8

    Re: specific text in a cell should return a text in another cell

    Thanks AlKey

    Works well. Solved easily

  8. #8
    Registered User
    Join Date
    09-28-2016
    Location
    sydney
    MS-Off Ver
    13
    Posts
    8

    Re: specific text in a cell should return a text in another cell

    Thank you

    Works well

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: specific text in a cell should return a text in another cell

    If you have many codes you could create a table like this...

    Data Range
    A
    B
    C
    D
    E
    1
    ------
    ------
    ------
    ------
    ------
    2
    A1B1-S1C1
    Stage 1
    S1
    Stage 1
    3
    A1B1-S2C1
    S3
    Stage 3
    4
    A1B1-S3C1
    Stage 3
    S4
    Stage 4
    5
    A1B1-S4C1
    Stage 4
    S7
    Stage 7
    6
    A1B1-S5C1
    7


    This formula entered in B2 and copied down:

    =IFERROR(LOOKUP(1E100,SEARCH(D$2:D$5,A2),E$2:E$5),"")
    Last edited by Tony Valko; 09-29-2016 at 08:14 AM.

  10. #10
    Registered User
    Join Date
    09-28-2016
    Location
    sydney
    MS-Off Ver
    13
    Posts
    8

    Re: specific text in a cell should return a text in another cell

    Dear Tony

    thanks..it works great

    I am new to this function. Can you explain what is the meaning of

    1E+100 and other contained in the brackets

    Many thanks

  11. #11
    Valued Forum Contributor
    Join Date
    06-21-2013
    Location
    Bangladesh
    MS-Off Ver
    Excel 2000, Excel XP, Excel 2002, Excel 2007, Excel 2010, Excel 2013
    Posts
    975

    Re: specific text in a cell should return a text in another cell

    If all of your data are as like as ****-S***, then you can use this formula also :
    Please Login or Register  to view this content.
    But this formula will work for 1 digit stage only (1-9).

    If all of your data are as like as ****-S**C**, then you can use this formula :
    Please Login or Register  to view this content.
    This will work for any digit.
    Last edited by sanram; 09-29-2016 at 07:58 PM.

  12. #12
    Registered User
    Join Date
    09-28-2016
    Location
    sydney
    MS-Off Ver
    13
    Posts
    8

    Re: specific text in a cell should return a text in another cell

    Dear Sanram

    Thanks a lot..took some time to understand

  13. #13
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: specific text in a cell should return a text in another cell

    Quote Originally Posted by rao2016 View Post
    Can you explain what is the meaning of 1E+100 and other contained in the brackets
    Here's how that works...

    Data Range
    A
    B
    C
    D
    E
    1
    ------
    ------
    ------
    ------
    ------
    2
    A1B1-S1C1
    Stage 1
    S1
    Stage 1
    3
    S3
    Stage 3
    4
    S4
    Stage 4
    5
    S7
    Stage 7
    6


    This formula entered in B2:

    =IFERROR(LOOKUP(1E100,SEARCH(D$2:D$5,A2),E$2:E$5),"")

    This expression searches for each of the substrings in D2:D5 within the larger string in A2:

    SEARCH(D$2:D$5,A2)

    If the substring is found the SEARCH function returns the starting position number of the substring. This will be a number from 1 to 32767 (the max number of characters allowed in a cell). If the substring is not found the SEARCH function returns a #VALUE! error:

    SEARCH("S1","A1B1-S1C1") = 6
    SEARCH("S3","A1B1-S1C1") = #VALUE!
    SEARCH("S4","A1B1-S1C1") = #VALUE!
    SEARCH("S7","A1B1-S1C1") = #VALUE!

    SEARCH("S1","A1B1-S1C1") = 6 - The substring "S1" was found starting at character number 6 within the larger string.

    Now we have this array:

    {6;#VALUE!;#VALUE!;#VALUE!}

    =IFERROR(LOOKUP(1E+100,{6;#VALUE!;#VALUE!;#VALUE!},E$2:E$5),"")

    1E+100 is scientific notation for the very large number 1 followed by 100 0s. Scientific notation is a "shorthand" method of expressing very long numbers.

    The way that LOOKUP works is if the lookup value of 1E+100 is larger than any other number within the array then LOOKUP will match the last number in the array.

    The last number in the array is 6 (it's also the only number in the array).

    LOOKUP will return the value in E2:E5 that corresponds to the 6 in the array:

    6: E2
    #VALUE!: E3
    #VALUE!: E4
    #VALUE!: E5

    E2 = String 1

    LOOKUP(1E+100,SEARCH(D$2:D$5,A2),E$2:E$5) = String 1.

    If none of the substrings in D2:D5 are found then the array would be all #VALUE! errors and the result of the LOOKUP function would be #VALUE!.

    We use the IFERROR function to trap any errors and return a blank "" instead.

    So:

    =IFERROR(LOOKUP(1E+100,SEARCH(D$2:D$5,A2),E$2:E$5),"")

    = String 1

  14. #14
    Registered User
    Join Date
    09-28-2016
    Location
    sydney
    MS-Off Ver
    13
    Posts
    8

    Re: specific text in a cell should return a text in another cell

    Tony

    Thanks so much. What a great explanation.

  15. #15
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: specific text in a cell should return a text in another cell

    You're welcome. Thanks for the feedback!

+ 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] If cell A contains specific text and cell b contains specific text then return this value
    By king10001 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-05-2016, 08:47 AM
  2. [SOLVED] Return Cell Value if Contains Specific Text
    By MausDef in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-14-2015, 07:41 AM
  3. Look up several values in a cell and return a specific text
    By peterromer in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 10-27-2014, 12:03 PM
  4. [SOLVED] If cell contains specific text, return that text
    By kazphilips in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-12-2014, 09:41 AM
  5. [SOLVED] If a cell contains a specific text than return a value
    By dcdeez in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 06-04-2013, 08:31 AM
  6. [SOLVED] Help to return only first 12 characters when a cell contains specific text
    By ports83 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-25-2012, 10:30 PM
  7. Replies: 3
    Last Post: 06-20-2012, 07:16 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