Forum Discussion
Need to search multiple words in a cell and get the output based on the word found.
- Jun 27, 2021
If you have Excel 2019 or Excel in Microsoft 365, enter the following formula in B1:
=TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH({"Generic Mailbox","Distribution","Non-standard","NSSR"},A1)),{"Shared Mailbox","DL","Corporate Request","Non-Standard Service Request"},""))
This allows for more than one of the search terms in a cell.
Otherwise:
=IFERROR(INDEX({"Shared Mailbox","DL","Corporate Request","Non-Standard Service Request"},MATCH(TRUE,ISNUMBER(SEARCH({"Generic Mailbox","Distribution","Non-standard","NSSR"},A1)),0)),"")
Fill down from B1.
If you have Excel 2019 or Excel in Microsoft 365, enter the following formula in B1:
=TEXTJOIN(", ",TRUE,IF(ISNUMBER(SEARCH({"Generic Mailbox","Distribution","Non-standard","NSSR"},A1)),{"Shared Mailbox","DL","Corporate Request","Non-Standard Service Request"},""))
This allows for more than one of the search terms in a cell.
Otherwise:
=IFERROR(INDEX({"Shared Mailbox","DL","Corporate Request","Non-Standard Service Request"},MATCH(TRUE,ISNUMBER(SEARCH({"Generic Mailbox","Distribution","Non-standard","NSSR"},A1)),0)),"")
Fill down from B1.
Hi HansVogelaar
Just new around here and saw your formula that was almost great for what I need. Almost because it keeps giving me inaccurate results.
I just know some basic stuff in Excel and I'm not able to go through this.
So I have this data below where I need to insert in C2:C5 a formula that will return as follows:
If "[INTERN]" is found in the cell, output should be INTERN
If "Offensive" is found in the cell, output should be Offensive
If "[INTERN]" and "Offensive" is found in the cell, output should be INTERN Offensive
If none of the above, then the output should be "REGULAR"
I copied the formula and modified as needed, but something is not correct since for the last value it returns the same thing (C4 and C5 are the same). Would you be kind enough to help me solve this formula and have it return as I indicated in D2:D5? I'm struggling for some days now and no result. 🙂
Thanks so much for your help, looking forward to see where I did wrong. 😉
Razvan
- SBays123Jan 30, 2023Copper Contributor
I've read quite a few of your responses and they are all excellent, I have a request that is similar to these but adds one more element to it that I am unsure how to do...
I am needing to search cell A8 in my workbook for the following list of symbols. Cell A8 may contain as little as none of them or all of them. The symbols correspond to a price, I would like the output to sum up the price of each of the symbols found in cell A8. Hopefully you can help, thank you!
- HansVogelaarJan 30, 2023MVP
How does cell A8 list the symbols? Separated by commas, or by spaces, or by line breaks, or ...?
- A_Arf23Feb 01, 2023Copper ContributorHansVogelaar
You seem to be very knowledgeable about this. I have a similar question with more basic excel skills. I was trying to use a Vlookup but the data value I'm searching is actually a cell with a string of text and numbers (ie. AB FEE INV# 123456). If it finds a key word (there is at least 12-15 words to search) then I want it to output the corresponding flag (ie EXCLUDE, or INDX --also about 8-10 different words). Vlookup seems to work for this except the data value is not a single word or number and the key word is embedded within the text string.
Any suggestions? Thank you
- HansVogelaarAug 24, 2022MVP
Like this:
=IF(ISNUMBER(SEARCH("[INTERN]",A2)),IF(ISNUMBER(SEARCH("Offensive",A2)),"INTERN Offensive","INTERN"),IF(ISNUMBER(SEARCH("Offensive",A2)),"Offensive","Regular"))
- Razvan1610Aug 24, 2022Copper ContributorThank you very much for this HansVogelaar
It is indeed a great tool this Excel in the hands of someone who knows how to use it.
Many greetings from Romania.- HansVogelaarAug 24, 2022MVP
You're welcome (greetings from The Netherlands)