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".
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.
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.
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,"")
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.
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.
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With