+ Reply to Thread
Results 1 to 10 of 10

Search and Return Phrase From Cell

  1. #1
    Registered User
    Join Date
    02-17-2019
    Location
    Texas
    MS-Off Ver
    365
    Posts
    2

    Search and Return Phrase From Cell

    I have a worksheet that contains thousands of cells, each with data that are separated by commas. For instance, the first three cells could be:

    Active, Tim's Client, Texas Clinic, XYZ Insurance
    Active, Mark's Client, Florida Clinic, ABC Insurance
    Active, LMN Insurance, Michigan Clinic, Sally's Client

    I need to search the cells and return only the text "Tim's Client" or "Mark's Client" or "Sally's Client" into a cell by itself so I can setup a pivot table based on each employees clients. The employees aren't always in the same sequence within the cell, so using "text to columns" won't produce a consistent list.

    I saw one forum that suggested referencing a list of employee's by using the following formula ("things" is the name of their list in the example) to return the first match, since there's never a case where two employees would be listed in the same cell:

    {=INDEX(things,MATCH(TRUE,ISNUMBER(SEARCH(things,A1)),0))}

    I couldn't get this to work though. Is there a better way, or a change that I need to make to this formula?

  2. #2
    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
    79,369

    Re: Search and Return Phrase From Cell

    Welcome to the forum!

    Will you please attach a sample Excel workbook? We are not able to work with or manipulate a picture of one and nobody wants to have to recreate your data from scratch.

    1. Make sure that your sample data are REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired results are also shown (mock up the results manually).

    3. Make sure that all confidential data is removed or replaced with dummy data first (e.g. names, addresses, E-mails, etc.).

    4. Try to avoid using merged cells as they cause lots of problems.

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

    Please pay particular attention to point 2 (above): without an idea of your intended outcomes, it is often very difficult to offer appropriate advice.
    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.

  3. #3
    Registered User
    Join Date
    02-17-2019
    Location
    Texas
    MS-Off Ver
    365
    Posts
    2

    Re: Search and Return Phrase From Cell

    Sorry about that. Here you go...
    Attached Files Attached Files

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Search and Return Phrase From Cell

    Please try at C2 and drag down

    =LOOKUP(1,-SEARCH($A$2:$A$4,B2),$A$2:$A$4)

  5. #5
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,133

    Re: Search and Return Phrase From Cell

    Check the attached workbook and see if it is OK for you ...

    .
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    10-15-2018
    Location
    MA, USA
    MS-Off Ver
    2010, 2019
    Posts
    1,616

    Re: Search and Return Phrase From Cell

    Is there any virtue in eliminating the need for column-A in the provided "search example.xlsx"? If so then the following formula relies on column-B only, but at the cost of more complexity than either Bo or Timma's solutions.

    In D2 entered as an array formula: CTRL-SHIFT-ENTER then copied down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    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
    79,369

    Re: Search and Return Phrase From Cell

    Haluk - Sorry for off-topic interjection:

    Although there is no official rule regarding this behaviour, we request that wherever possible both the question AND the answer be provided in substantive detail here within the thread. An attached workbook is an excellent aid for posing a question and offering a solution, but solely doing that with no in thread explanation makes it difficult for researchers to understand or consider the Q & A of this thread without downloading what may be a pointless doc to them, if they can do that at all. Doing that also hides the content from search engines so others may never benefit from this.

    I'm sure you understand and will comply.

  8. #8
    Valued Forum Contributor Haluk's Avatar
    Join Date
    02-14-2019
    Location
    Turkiye
    MS-Off Ver
    2010 - 64 Bit on Windows-11 (22 H2) 64 Bit
    Posts
    1,133

    Re: Search and Return Phrase From Cell

    Quote Originally Posted by AliGW View Post
    ....
    ..
    I'm sure you understand and will comply.
    I just attached the workbook instead of giving the formula to be used because; my Excel settings are purely different then yours. Meaning; its rather hard for me to replace ";" with "," ... etc. in the formulas everywhere.

    But its OK .... I will do my best

    .

  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
    79,369

    Re: Search and Return Phrase From Cell

    Not really. All you have to do is add a caveat: "You may need to replace , with ; for your locale."

    Or you can use this tool: https://en.excel-translator.de/translator/

    Pleae do as I have asked. Thanks.

  10. #10
    Valued Forum Contributor
    Join Date
    10-29-2012
    Location
    Mojokerto,Indonesia
    MS-Off Ver
    Excel 2007
    Posts
    554

    Re: Search and Return Phrase From Cell

    =TRIM(MID(SUBSTITUTE(B2,",",REPT(" ",LEN(B2))),FIND("Client",SUBSTITUTE(B2,",",REPT(" ",LEN(B2))))-LEN(B2),LEN(B2))&" Client")
    copy down

+ 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] Search multiple phrases in a cell and return the first phrase found
    By pmeltzers in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 12-26-2017, 04:07 PM
  2. [SOLVED] Macro to search for phrase and delete that cell and 1 cell to the right.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-25-2017, 01:51 PM
  3. [SOLVED] can't search word or phrase in my database
    By kensho in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-15-2015, 06:01 AM
  4. [SOLVED] Search using a Word/Phrase
    By hiteshasrani43 in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 03-05-2015, 01:02 AM
  5. Replies: 2
    Last Post: 10-09-2014, 05:14 AM
  6. Function to return text from phrase X to phrase Y
    By razr in forum Excel General
    Replies: 3
    Last Post: 05-06-2009, 05:52 PM
  7. [SOLVED] Search a Range for a phrase and Format cell if found
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2005, 06:05 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