Multiple returns from a cell lookup - excel

I have text string in cells that I want to interrogate and then have all matching text values displayed in one cell.
I'm currently using:
=IF(ISNUMBER(SEARCH("horse",G360)),
"horse",
IF(ISNUMBER(SEARCH("cat",G360)),
"cat",
IF(ISNUMBER(SEARCH("monkey",G360)),
"monkey",
IF(ISNUMBER(SEARCH("donkey",G346)),
"donkey"))))
However of course this only shows the first matching value not ALL matching values. How would I do this?
If a cell contained text "blah cat blah blah monkey blah blah horses" the formula result would be "Horse, Monkey" not just "Horse".

In the sample even CAT will also come in I suppose.
For limited number of items case you could try:
=SUBSTITUTE(TRIM(CONCATENATE(
IF(ISNUMBER(SEARCH("horse",G360)),"horse "," "),
IF(ISNUMBER(SEARCH("cat",G360)),"cat "," "),
IF(ISNUMBER(SEARCH("monkey",G360)),"monkey "," "),
IF(ISNUMBER(SEARCH("donkey",G346)),"donkey "," ")
))," ",", ")

Related

M Function to trim specific range

I need to trim in Power Query a column that has the following structure:
"ABC (XI 011)"
"ABC (XI1 02)"
I need to trim/ get every value between "(" and " ".
And I need to trim/ get every value between " " and ")".
For the 2 examples above the result should be for the first column:
XI
XI1
And for the second column:
011
02
Is there any chance to get this result with Power Query functions?
Use such code:
let
Source = #table({"col"},{{"ABC (XI 011)"}, {"ABC (XI1 02)"}}),
split = Table.SplitColumn(Source, "col", (x)=>Text.Split(Text.BetweenDelimiters(x, "(", ")")," "))
in
split

Ms Excel IF ISNUMBER SEARCH for multiple text using AND or OR operator

This is my excel data
As you can see in B2, this formula only search for the first text it found and will ignore the rest.
What I'm trying to accomplish is if 2 or more different texts are found like B2, is it possible to print another message ... let say Apple & Banana found
This is my original excel formula for your reference:
=IF(ISNUMBER(SEARCH("apple",A2)),"Apple",
IF(ISNUMBER(SEARCH("banana",A2)),"Banana",
IF(ISNUMBER(SEARCH("cher",A2)),"Cherries",
"Other")))
I have tried and tried and thought hmmm why don't I simply add a SUBSTITUTE function...and it worked ;o)
Just in case there is someone out there looking for this:
=SUBSTITUTE(TRIM(CONCATENATE(IF(ISNUMBER(SEARCH("apple",A2)),"Apple "," "),
IF(ISNUMBER(SEARCH("banana",A2)),"Banana "," "),
IF(ISNUMBER(SEARCH("cher",A2)),"Cherries "," "),
IF(SUM((ISNUMBER(SEARCH({"apple","banana","cher"},A2,1)))+0)=0,"Other "," "))),"Apple Banana","Both")
See if following formula tweak helps you:
=TRIM(CONCATENATE(IF(ISNUMBER(SEARCH("apple",A2)),"Apple "," "),
IF(ISNUMBER(SEARCH("banana",A2)),"Banana "," "),
IF(ISNUMBER(SEARCH("cher",A2)),"Cherries "," "),
IF(SUM((ISNUMBER(SEARCH({"apple","banana","cher"},A2,1)))+0)=0,"Other "," ")))&" found"
Here is my proposal :
You create a Table with your KeyWord and Result in two columns
(columns K for KeyWord and L for Result).
You change your formula like this
=IF(ISNUMBER(SEARCH(K2,A2)),L2, IF(ISNUMBER(SEARCH(K3,A2)),L3, IF(ISNUMBER(SEARCH(K4,A2)),L4, "Other")))
After that, is more easy to add new KeyWord, to change the order if you want to prioritize a KeyWord more than an other.
You can't use more than 63 KeyWords, but you can create a second formula from 64 to 126.

Find key word exactly from a text field in Excel

I have a formula below:
=ISNUMBER(SEARCH("Perso",$A2))
I want to it return True for the field that exactly contains my key word "Perso"
However, from the image you can see that both rows return True, because the word "person" also contains "perso".
Can anyone provide some suggestions on how can I achieve my goal in Excel.
Include the deliminating space:
=ISNUMBER(SEARCH(" Perso "," " & $A2 & " "))

Excel, MID, SEARCH Error

I have two strings, i want to extract the number in the middle "2200" i am using the formula
=VALUE(MID(C3,SEARCH("_",C3)+11,4))
C3 is where the string is. this formula working on "string 2" and give me the value i am looking for "2200" but doesn't work for "String 1" i get #VALUE!. if i change the formula
=VALUE(MID(C3,SEARCH("_",C3)+10,4))
it works for "String 1" but doesn't work for "String 2" How can i have same formula work in both situations?
String 1: ABC_1A1B_33C_2200_4AB_ABC4_4800
String 2: ABC_10A1B_33C_2200_4AB_ABC4_4800
thx,
This should work as long as the example 2200 is always 4 digits long:
=LEFT(REPLACE(D7,1,FIND("#",SUBSTITUTE(D7,"_","#",3)),""),4)
If the value you wish to extract is always in the fourth position, then you can try:
=INDEX(TRIM(MID(SUBSTITUTE(C3,"_",REPT(" ",99)),seq_99,99)),4,1)
where seq_99 is a Named Formula that refers to:
=IF(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))=1,1,(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))-1)*99)
seq_99 will return an array: {1,99,198,297,...,25146}
This does not care as to the length, only that it is the forth block:
=TRIM(MID(SUBSTITUTE(A1,"_",REPT(" ", 999)),3*999,999))
Note
The above returns a text string that looks like a number. If a number is what is wanted then replace the TRIM with --
=--MID(SUBSTITUTE(A1,"_",REPT(" ", 999)),3*999,999)
This solution is based on the static position of the number being between the third and fourth underscore character.
=--TRIM(MID(SUBSTITUTE(SUBSTITUTE(A2, "_", REPT(" ", LEN(A2)), 4), "_", REPT(" ", LEN(A2)), 3), LEN(A2), LEN(A2)))
Note the double-unary (aka double-minus or --) that converts text-that-looks-like-a-number to a true number.

Excel search function - match case

I'm trying to find if cells have specific string or not. This is how I do it right now:
=IF(ISNUMBER(SEARCH("AAA";L2)); "yes"; "no")
If a cell has "AAA", I write to another cell yes, if not, I write no...
The problem is that it also gets true answer for AAA1 or AAA1234 for an example, how can I return true statement only for AAA?
If there are trailing numbers/charcters in my string, I want to reutrn no, but the cell itself might be longer... for and example "AAA BVC BFD2" etc. Then I want to return true. False if for an example: "AAA1 BVC BFD2"
As I mentioned in comments, you can use this one:
=IF(ISNUMBER(SEARCH(" AAA ";" " & L2 & " ")); "yes"; "no")
How it works:
suppose you have a string "AAA BVC BFD2" in cell L2.
" " & L2 & " " part modifies this string to " AAA BVC BFD2 " (note, there're additional spaces in the end and in the beggining)
now, we're able to search " AAA " (with spaces) in modified string " " & L2 & " ".
I'm clearly missing something as it seems to me that you could do this with something as simple as
=IF(LEFT(A1,4)="AAA ","yes","no")
I don't think the question is particularly clear, if I'm being honest...

Resources