Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you do multiple options for the =if(isnumber(search))) formula in excel?

Tags:

excel

This formula looks for the string "BFA" inside cell I3. If found, it returns "BFA"; if not, it returns "No".

=IF(ISNUMBER(SEARCH("BFA",I3)),"BFA","No")

How can I modify this to work for multiple strings at the same time? For example, if any of {"BFA", "MFA", "BA", "MA"} is found, then return what was found; if not, return "No".

like image 259
Ka Mok Avatar asked Jan 09 '15 19:01

Ka Mok


People also ask

How do you write an IF THEN formula in Excel with multiple criteria?

Another way to get an Excel IF to test multiple conditions is by using an array formula. To complete an array formula correctly, press the Ctrl + Shift + Enter keys together. In Excel 365 and Excel 2021, this also works as a regular formula due to support for dynamic arrays.

Can IF statement have 2 conditions?

Use two if statements if both if statement conditions could be true at the same time. In this example, both conditions can be true. You can pass and do great at the same time. Use an if/else statement if the two conditions are mutually exclusive meaning if one condition is true the other condition must be false.

How do you do multiple IF functions in Excel?

Use the IF function, one of the logical functions, to return one value if a condition is true and another value if it's false. For example: =IF(A2>B2,"Over Budget","OK") =IF(A2=B2,B4-A4,"")

How does Isnumber search work in Excel?

The Excel ISNUMBER Function[1] is categorized under Information functions. The function checks if a cell in Excel contains a number or not. It will return TRUE if the value is a number and if not, a FALSE value. For example, if the given value is a text, date, or time, it will return FALSE.


2 Answers

This is absolutely possible, but I would recommend a different approach:

=INDEX({"BFA","MFA","BA","MA","No"},MATCH(1,COUNTIF(I3,"*"&{"BFA","MFA","BA","MA",""}&"*"),0))

You can also put the items to look for in a range of cells and their results in the range next to them. So if you had the following setup:

    _____A____  ___B__
1   Search For  Return
2   BFA         BFA
3   MFA         MFA
4   BA          BA
5   MA          MA
6               No

Then the formula would look like this:

=INDEX($B$2:$B$6,MATCH(1,COUNTIF(I3,"*"&$A$2:$A$6&"*"),0))

For making it scalable and updatable I recommend putting what to search for and what that search should return if found in a range as shown. You could put it on a separate sheet or hide those columns if preferred.

like image 145
tigeravatar Avatar answered Sep 22 '22 14:09

tigeravatar


You can use this version with LOOKUP:

=IFERROR(LOOKUP(2^15,SEARCH({"BFA","MFA","BA","MA"},I3),{"BFA","MFA","BA","MA"}),"No")

The SEARCH function returns an array of either numbers or errors (depending on whether each string is found or not). When you lookup 2^15 in that array, the match is always with the last number, and then LOOKUP returns the corresponding text string. If there are no matches, you get #N/A and IFERROR converts that to "No".

So if you have any cells that contain both "BFA" and "BA", for example, the formula will return the last one in your list, i.e. "BA".

like image 20
barry houdini Avatar answered Sep 20 '22 14:09

barry houdini