+ Reply to Thread
Results 1 to 10 of 10

IF range of cells contains string of text, return contents of cell where string is found

  1. #1
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    IF range of cells contains string of text, return contents of cell where string is found

    Just as title says:

    IF range of cells contains string of text, return contents of cell where string is found

    For example

    Col A

    dog
    cat


    Col B

    the dog ran
    the (cat) walked
    the (dog) ran
    the cat walked

    So a formula that would search for the contents in A1 and return the entire cell B1

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    Hi nobodyukno,

    Use below formula (entered with ctrl shift enter)

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



    search string and return from next col.xlsx
    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey
    +91 9810929744
    dilipandey@gmail.com

  3. #3
    Registered User
    Join Date
    04-14-2009
    Location
    The World
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    HI
    i cell D1 write your Criteria
    for example dog

    in cell E1 use this CSE formula
    Please Login or Register  to view this content.
    the press Ctr+Shift+Enter

    copy it down

  4. #4
    Forum Contributor
    Join Date
    06-26-2013
    Location
    LAX
    MS-Off Ver
    Excel 2007,Excel 2010
    Posts
    363

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    Definitely there are better solutions. Try this formula.

    = IF(OR(IFERROR(SEARCH($A$1,B1),-1)>0,IFERROR(SEARCH($A$2,B1),-1)>0),B1,"")

    See attach file.

    b1-per-a1.xlsx

  5. #5
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    Quote Originally Posted by Yahya View Post
    HI
    i cell D1 write your Criteria
    for example dog

    in cell E1 use this CSE formula
    Please Login or Register  to view this content.
    the press Ctr+Shift+Enter

    copy it down
    Ive had the best luck with this formula so far but still doesn't return exactly what I want.

    Does it make a difference if my criteria is on one sheet and what I'm searching through is about 450 rows on another sheet? And then returning the cell where it found my criteria in the sheet with where the criteria is located.

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

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    Perhaps

    =VLOOKUP("*"&A1&"*",B:B,1,FALSE)

  7. #7
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    Quote Originally Posted by Jonmo1 View Post
    Perhaps

    =VLOOKUP("*"&A1&"*",B:B,1,FALSE)
    Could you explain what the B:B part of the formula means?

    *EDIT*

    Nevermind just where the lookup values are located.

    Formula works perfectly! However, one caveat. In my spreadsheet, there's two values for the word "dog." One is in parentheses and the other is not. Is there anyway to adjust the formula so it only returns the cell containing the word dog and not (dog)?

    If it could search for the criteria cell and a space before and after the criteria cell, it would work perfectly.
    Last edited by nobodyukno; 07-03-2013 at 09:41 AM.

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

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    Try

    =VLOOKUP("* "&A1&" *"," "&B:B&" ",1,FALSE)

    IMPORTANT,
    This is an array formula now, and must be entered with CTRL + SHIFT + ENTER

  9. #9
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    Quote Originally Posted by Jonmo1 View Post
    Try

    =VLOOKUP("* "&A1&" *"," "&B:B&" ",1,FALSE)

    IMPORTANT,
    This is an array formula now, and must be entered with CTRL + SHIFT + ENTER
    Works perfectly! Thanks a lot!

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

    Re: IF range of cells contains string of text, return contents of cell where string is fou

    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)

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