I am using the following formula to search for a string and return a value
IF(ISNUMBER(SEARCH("CHA*",B:B),"CINEMA","")
If I want to search for multiple strings whats the formula?, I've tried the following but it isn't returning anything
IF(ISNUMBER(SEARCH({"odeon*","vue*"},B:B),"CINEMA","")
Try this:
=IF(COUNT(SEARCH({"odeon*","vue*"},B:B))>0,"CINEMA","")
Another way:
=IF(OR(ISNUMBER(SEARCH({"odeon*","vue*"},B:B))),"CINEMA","")
Use AND() if you require ALL substrings to match:
=IF(AND(ISNUMBER(SEARCH({"odeon*","vue*"},B:B))),"CINEMA","")
For starters, you're missing a ) on either formula. And for them to work anyway, you should, as Taosique pointed out, use =IF(OR(ISNUMBER(SEARCH( if you need just one substring, or =IF(AND(ISNUMBER(SEARCH( if you require both.
Good luck!
Related
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.
Ok, so this works:
OR(IFERROR(FIND("ab",A1,1),0),IFERROR(FIND("12",A1,1),0))
tested here :
I followed one of the links and the version like this:
=IF(COUNT(SEARCH({"Romney","Obama","Gingrich"},C1)),1,"")
worked as expected for me, but if the search is isolated it then fails and I have not found an explanation ...
Like other array-style formulas, the part that delivers the array has to be enclosed in some sort of aggregate function to make it scan through the array - otherwise it only looks at the first element of the array. So anything like COUNT, SUM, SUMPRODUCT will do the trick.
My preferred one is
=OR(ISNUMBER(SEARCH({"a","b","c"},A1)))
because you can easily change it to this if you want AND logic:
=AND(ISNUMBER(SEARCH({"a","b","c"},A1)))
I have a problem on a VLOOKUP function in an Excel.
Basically i am trying to search a route from another spreadsheet, using a reference number.
- example: I put in a reference (lets say WPC 80) and i want to get a route (for this ex it should be Pitesti - Wrzesnia:
The problem is that it gives me something random.
I know that maybe im not using it correctly, but do you have any idea?
Thank you!
As noted in VLOOKUP documentation, the last parameter contols whether to use Exact Match or Approximate Match.
Try using exact matching:
=VLOOKUP(..., FALSE)
Sorry not enough rep to post a comment. When using vlookup, and the Range_Lookup parameter is TRUE, the lookup table must be sorted in ascending order, or you will get unusual results. Also ensure you put an absolute reference on the lookup table for when you drag it down.
Better use INDEX and MATCH combination, faster and far more reliable.
I would like to find out if a string within a cell in Excel 2010 contains any of the following, and then return a '1'.
?dementia
? dementia
dementia?
dementia ?
I've tried some formulas but they don't seem able to get past the use of the wildcard and the string when combined.
Would anyone have any pointers or advice?
Here is a combination of the suggested answers, and my own work around:
This is the formula you need:
=IF(IFERROR(FIND(A2,$C$3),0)>0,1,0)
where A2 is the string that you are trying to check.
Assuming you don't want to include word ? word and return 1, you can use something like this:
=IF(OR(LEFT(A1,1)="?",RIGHT(A1,1)="?"),1,"")
You will want to use the FIND function (Documentation).
Make sure your search term in in quotation marks.
If you are still having trouble with wildcards, you can try the CHAR function (Documentation). It will return the character as a string. In your case, to get a ?, you would use CHAR(63). I use this chart to keep track of CHAR codes (just use the number and ignore the "Alt")
REVISED:
If I understand the question correctly, you are trying to search long string in a short string list.
The formula you can use is:
=ISTEXT(LOOKUP(99^99,SEARCH(SUBSTITUTE($A$2:$A$5,"?","|"),SUBSTITUTE(C2,"?","|")),$A$2:$A$5))*1
The problem with my prior formula is due to that ? mark because it is being treated as a wild card. Here I have replace it with | (you can change this to a character that you will never use but avoid ? and *). This should work for you now.
I like working with variables in Excel, it is useful converting everything between commas into a variable, but I got stuck in here, does anyone have an idea how to use array limitations with INDEX() function such as seen in the example?
This is an array formula in a table form:
{=INDEX([#Column1]=[Column1],MATCH(1,([Column2]="Ready"),0),0)}
it returns the right value for the first instance of [#Column1]=[Column1] but for the rest, the result is wrong.
A sample can be found in >>>here<<<.
I saved this in another language, please let me know if transcription of functions are incorrect when you open. I tested but..you know..
This does not need to be an array, use COUNTIF/S instead:
=COUNTIF([Column1],[#Column1])=COUNTIFS([Column1],[#Column1],[Column2],"Ready")
Is there an "IN" type function like the one used in sql that can be used in excel? For example, if i am writing an If statement in excel and I want it to check the contents of a cell for 5 different words can i write something like:
=If(A1=IN("word1","word2","word3","word4","word5"),"YES","NO")
You could use MATCH :
=MATCH(A1, {"word1","word2","word3","word4","word5"}, 0)
which will return the index of the matching item in the array list. The trailing 0 means it should be an exact match. It will return #N/A if it isn't there, so you can tag a IF(ISNA( onto the front to make it behave like your "IN":
=IF(ISNA(MATCH(A1, {"word1","word2","word3","word4","word5"}, 0)),"NO","YES")
Note the change in order of the "YES" and "NO"
=IF(OR(A1={"word1","word2","word3","word4","word5"}),"YES","NO")
I think an improvement on
=IF(OR(A1={"word1","word2","word3","word4","word5"}),"YES","NO")
would be to use
=IF(OR(A1={"word1","word2","word3","word4","word5"}),A1,"NO");
which is more like the SQL's IN clause.
Use the OR function. It operationes very similiar to what you are looking for.
IF(OR(A1="word1",A1="word2",A1="word3")=TRUE,"Yes","No")
Also doesn't require the ctrl+shift+enter when using.