I'm trying to do a search for multiple strings in a cell with an OR-condition in Excel 2016.
E.g. I have a string abcd1234
and I want to find ab OR 12
.
I'm using the german version where the function SEARCH
is called SUCHEN
and it should behave the same way.
I found this answer which suggests this solution:
SEARCH({"Gingrich","Obama","Romney"},C1)
.
I also found this website which suggests the same syntax:
SEARCH({"red","blue","green"},B5)
Same with this website:
SEARCH({"mt","msa","county","unemployment","|nsa|"},[@Tags])
So they basically say make a list of search terms separated by commas enclosed by curly braces and you're good.
But putting these into Excel 2016 just results in the usual meaningless Excel error message which says there was an error with the formula and it's always highlighting the whole part in curly braces.
Taking the first example the only way I could get Excel to not throw its error message was to change the syntax like this:
=SEARCH({"Gingrich";"Obama";"Romney"};C1)
But separating the search terms with semicolons doesn't apply the OR-condition correctly, so this is not the solution.
I'm aware from this answer that I could make separate searches and string them together with a condition, but I would like to avoid that, and I also want to know why the syntax that is supposed to work as confirmed by multiple sources is not working for me.
EDIT:
Okay, I'm starting to understand this, thanks to Solar Mike:
The code =IF(COUNT(SEARCH({"Romney","Obama","Gingrich"},A1)),1,"")
works indeed perfectly fine.
Also =COUNT(SEARCH({"Romney","Obama","Gingrich"},A1))
works.
But =SEARCH({"Romney","Obama","Gingrich"},A1)
does not.
Also =ISNUMBER(SEARCH({"Gingrich","Obama","Romney"},A1))
does not work.
I'd love to know the reason why.