+ Reply to Thread
Results 1 to 10 of 10

Search for specific Words within a sentence and return the specific word if found

  1. #1
    Registered User
    Join Date
    08-04-2022
    Location
    Germany
    MS-Off Ver
    365
    Posts
    3

    Cool Search for specific Words within a sentence and return the specific word if found

    Hey everybody, I dont know how to exactly describe it, but I will try:

    I do have a long list of titles of SAP-entries which are following a specific nomenclature. They are all named like: "prefix_specific word". I do have a total amount of 11 words which can stand directly after the prefix, replacing "specific word" within "prefix_specific word". I would like, that Excel is analyzing my SAP-entries in regard to the specific word an should return/extract this specific word to a new cell.

    As an example I have a title of: "prefix_specific word_further words explaining more". The formula should return in the new cell only "specific word" if this word is found within the cell. It should be something like an automatic search/filter function.

    I thought I can build something like a =XLOOKUP, but I was not able to do it.

    Do you have any idea?

    Thank you very much,
    Chris

  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,662

    Re: Search for specific Words within a sentence and return the specific word if found

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? However, please give us an indication of the approximate number of rows of data you want the solution to work with (100, 1000, 100,000 or whatever). Please DO NOT attach a picture of an Excel sheet (I do not have the patience to re-type any/all your stuff before starting).

    1. It does NOT have to be your real sheet - mock up a SAMPLE if you need to. But not 1000's of rows!!! It makes manual checking so tedious. Whatever you do... make sure that all confidential information is removed first!!

    2. Make sure that your sample data are truly REPRESENTATIVE of your real data. For example, don't show text in a column if it's really a number. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    3. Make sure that your desired solution is also shown (mock up the results manually). To be honest, I am not interested in seeing a non-working formula... or a pile of blank cells. However, I am very interested in seeing your EXPECTED results in their EXPECTED location.

    4. Try not to use merged cells. They cause lots of problems and are DEFINITELY best avoided!

    Unfortunately the attachment icon doesn't work at the moment. So... for a new thread (1st post), scroll to Manage Attachments and for a new post in your existing thread click on Go Advanced (below the Edit Window) while composing your reply, then scroll down to and click on Manage Attachments. In both cases, the Upload window will open. Click on Browse and navigate to (and double-click) the file icon that you want to attach, then click on Upload and then on Close this Window to return to the Edit window. When you have finished composing your post, click on Submit Post.
    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 TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,596

    Re: Search for specific Words within a sentence and return the specific word if found

    Maybe this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,477

    Re: Search for specific Words within a sentence and return the specific word if found

    Quote Originally Posted by TMS View Post
    Maybe this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    And, if your formula does work for the OP, but if he (or a reader of this thread) does not have the TEXTSPLIT function yet, then this formula will also work....
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-04-2022
    Location
    Germany
    MS-Off Ver
    365
    Posts
    3

    Question Re: Search for specific Words within a sentence and return the specific word if found

    Hey everybody,

    thanks for the quick reply. I think that trimming will not work due to potential differences in the length of the first prefix.
    I attached an example to make clear what I want to do.
    I would like to define search strings like in line E. There I wrote down 5 names. Excel should search for this names in line B and should write down the result in line C if Excel found a name which is defined in E to the line C.
    If no name could be found, Excel should display "others".

    Thank you very much and have a nice day,
    Chris

    Example.xlsx

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,979

    Re: Search for specific Words within a sentence and return the specific word if found

    This ??

    =IF(ISNUMBER(SEARCH(E2,$B$2:$B$6)),E2,"Others")
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  7. #7
    Registered User
    Join Date
    08-04-2022
    Location
    Germany
    MS-Off Ver
    365
    Posts
    3

    Re: Search for specific Words within a sentence and return the specific word if found

    Hey John,

    thank you for your reply.
    Looks good, but now imagine, that I will have around 300 entries in line B and a search string of around 5 names in line E. I think that the formula is not working anymore if the order is mixed-up?
    For example, if I add further lines with ABC_Malfoy_Expecto the formula answers with "Others" instead of Malfoy again.

    Thank you very much,
    Chris

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,596

    Re: Search for specific Words within a sentence and return the specific word if found

    Edit: missed the sample file.

    If there is only one underscore, how would we know if it is the first or second that is missing?
    Last edited by TMS; 08-04-2022 at 02:37 PM.

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,979

    Re: Search for specific Words within a sentence and return the specific word if found

    Change the range ????

  10. #10
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Search for specific Words within a sentence and return the specific word if found

    Might be over-complicating it but how about:

    =LET(x,BYROW(IF(ISNUMBER(SEARCH(TRANSPOSE($E$2:$E$6),$B$2:$B$6)),TRANSPOSE($E$2:$E$6),""),LAMBDA(row,TEXTJOIN("_",1,row))),IF(x="","Others",x))

    If it finds more than one term then it will return them all separated by an underscore.

+ 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. Looking for a code that will return specific result if specific text is found
    By SpreadSheetMom in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-17-2020, 04:32 PM
  2. Find specific words in a list and populate the word found in column C
    By catesgene in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-18-2019, 12:59 PM
  3. VBA Search a set of strings, return specific data if found
    By banaanas in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-08-2014, 03:54 AM
  4. A word search to return words found in given fields
    By JonBrett in forum Excel General
    Replies: 2
    Last Post: 03-28-2014, 10:16 PM
  5. Search for Identifier Words and Return a Specific Value
    By uberathlete in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-12-2014, 07:29 PM
  6. Replies: 1
    Last Post: 01-25-2011, 10:50 PM
  7. [SOLVED] search for a specific word and copy the word and the preceeding words until a comma
    By DHANANJAY in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-31-2005, 09:10 AM

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