+ Reply to Thread
Results 1 to 11 of 11

If Cell Includes Text, Display as Other Text

  1. #1
    Registered User
    Join Date
    04-15-2020
    Location
    Florida, USA
    MS-Off Ver
    2017
    Posts
    4

    If Cell Includes Text, Display as Other Text

    Hello.

    If a cell includes the text shown in A1, I need it to display the text in B1 in that cell instead.

    In other words, if D1 contains A1, then replace D1 with the text in B1. If D1 contains A2, replace D1 with the text in B2. Etc.

    So for the example in my attached spreadsheet.
    D1 should become "birds"
    D2 should become "fish"
    D3 should become "dogs"
    D4 should become "cats"

    (this is just an example. In my real spreadsheet, the word in B will not always be in A. So I do need the function to search D for the text in A, and then display B)

    What's my best method for achieving that?

    Thanks.
    Attached Files Attached Files
    Last edited by Lance Devore; 04-15-2020 at 12:00 PM.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: If Cell Includes Text, Display as Other Text

    Administrative note

    Welcome to the forum

    in your haste to solve your problem, you probably missed the yellow banner advising how to get answers faster by posting a sheet ?

    Please take a moment to read it and attach a sheet accordingly.

    Thanks you for helping us help you

  3. #3
    Registered User
    Join Date
    04-15-2020
    Location
    Florida, USA
    MS-Off Ver
    2017
    Posts
    4

    Re: If Cell Includes Text, Display as Other Text

    Sorry about that. I've updated the post with an attached sheet. Thanks.

  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: If Cell Includes Text, Display as Other Text

    Try this function in E1, then copied down:

    =LOOKUP(2, 1/(ISNUMBER(SEARCH($A$1:$A$4,D1))), $B$1:$B$4)

    In the case of multiple matches, it will return the LAST match from the list in column A.
    _________________
    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
    Registered User
    Join Date
    04-15-2020
    Location
    Florida, USA
    MS-Off Ver
    2017
    Posts
    4

    Re: If Cell Includes Text, Display as Other Text

    That works! Thanks so much. Now one problem. In my sheet there may be a case where E7, for example, already has "Goats" pre-filled in and there's no statement in D7. This function is is overwriting "Goats" to say "N/A" because there was no statement in D7. Is there a way for the function to do nothing if it doesn't find a statement in D7?

  6. #6
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: If Cell Includes Text, Display as Other Text

    Hi,
    you can add iferror into the existing formula:

    =IFERROR(LOOKUP(2, 1/(ISNUMBER(SEARCH($A$1:$A$4,D1))), $B$1:$B$4),"")

  7. #7
    Registered User
    Join Date
    04-15-2020
    Location
    Florida, USA
    MS-Off Ver
    2017
    Posts
    4

    Re: If Cell Includes Text, Display as Other Text

    Perfect, thank you! That's exactly what I needed.

  8. #8
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: If Cell Includes Text, Display as Other Text

    Great! glad this helps, now I need to understand JBeaucaire 's formula

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,756

    Re: If Cell Includes Text, Display as Other Text

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

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

    Re: If Cell Includes Text, Display as Other Text

    I'ts a trick Excel formula. You can see it in action by selecting the cell, then going to FORMULAS > EVALUATE FORMULA, then step through it one calculation at a time and watch it unfold from the inside out.

    A normal Lookup finds a value in one range, then returns a value from an adjacent range.

    In this trick version, the ISNUMBER(SEARCH) part is testing every search value in column A against the searchable string. The result is an array if TRUE/FALSE answers.

    When you divide the number 1 by the TRUE/FALSE answer array, you get a new array of decimal values and errors.

    Since the LOOKUP value is 2, that value never occurs in a series of decimal values, so LOOKUP defaults to the last closest value and uses that as the position of resolution. That position is then pulled from the adjacent range.

    In short, this trick always finds the "last useable match" in an array of possible matches.

  11. #11
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: If Cell Includes Text, Display as Other Text

    Very clever, and thank you for the extensive explanation.

+ 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. How to vlookup if some text cell includes another text cell
    By JaneMRO in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-20-2020, 02:55 PM
  2. [SOLVED] Formula to bring text which includes and exludes certain text
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-07-2019, 09:20 PM
  3. [SOLVED] Extract text from cell which includes a date?
    By hilton426 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 02-02-2016, 08:44 AM
  4. Replies: 2
    Last Post: 03-17-2014, 12:14 PM
  5. look up with cell range, concatentate and text that includes the asterix
    By joolzh13 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 01-25-2013, 07:57 AM
  6. [SOLVED] Counting Cells that includes exact match and also if a cell includes specific text
    By smclachlan in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-19-2012, 07:42 PM
  7. [SOLVED] Text that includes data from a designated cell?
    By Blades in forum Excel General
    Replies: 2
    Last Post: 06-27-2006, 08:10 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