Search multiple items returning error - excel

I have an excel formula that I want to return the rightmost data after finding one of three things. However if the first search term is not found it returns an error:
=IFERROR(RIGHT(A1, LEN(A1)-SEARCH({")",">","#"},A1)),"")
How can I make this work for all three search terms?
Currently the other search terms evaluate to #VALUE! which, if the first term is not found, is causing the formula to fail.

Try this modified version, entered as an Array formula (Press Ctrl-Shift-Enter rather than just Enter)
=RIGHT(A1, LEN(A1)-MAX(IFERROR(SEARCH({")",">","#"},A1),0)))
The Max get the largest result from Search.
If none of the characters appear in the string, it returns the whole string

Related

Excel search function with a list of things - array behaves weird?

I have a list of substrings and need to check if the text string in my cell contains any of these substrings. Exactly like here: https://exceljet.net/formula/cell-contains-one-of-many-things
However, the ISNUMBER(SEARCH(MySubstrings,A3)) behaves strangely. Instead of checking A3 against a list of substrings like ISNUMBER(SEARCH({dog, cat, egg},A3)) it automatically populates three subsequent cells to show results for checking A3 against every item on my list, one by one.
search without curly brackets
And when I enter the same thing as an array formula, it only checks for occurrence of the first substring from my list, in this case "dog".
search with curly brackets
Why does this not work? Thanks for your hints!
You're missing the SUMPRODUCT function as in the exceljet example. The argument passed to SUMPRODUCT is an array (in your example, a 1-by-3 array of TRUE or FALSE), which SUMPRODUCT turns into a single value (0 or 1):
=SUMPRODUCT(--ISNUMBER(SEARCH({"dog","cat","egg"},A3)))>0
An alternative formulation would be to wrap ISNUMBER with the OR function (still no need to enter as an array):
=OR(ISNUMBER(SEARCH({"dog","cat","egg"},A3)))

Finding a value from array in File Path [Excel]

I have a little problem with Excel.
I'm trying to compare if one of several specific words occur in a path.
This is what I do with the following function:
=IF(ISERROR(SEARCH($C$2:$C$4,A2)),"NO","YES")
However, the result is always "No".
Example data:
Does anyone have an idea?
SEARCH($C$2:$C$4,A2)
will return an array of a number or a #VALUE! errors.
If you wrap that in ISNUMBER it will return an array of TRUE;FALSE...
To see if ANY of the values are TRUE, wrap that in an OR and use that in your IF statement.
Of course, since this is an array formula, you have to enter it by holding down ctrl + shift while hitting Enter
=IF(OR(ISNUMBER(SEARCH($C$2:$C$4,A2))),"Yes","No")
You can see what is happening by using the Formula Evaluation tool
You can use SUMPRODUCT with ISNUMBER and SEARCH
=IF(SUMPRODUCT(--ISNUMBER(SEARCH(C2:C4,A2)))>0,"YES","NO")

Excel - IF Formula with a FIND

I have an excel document I have to process regularly, while awaiting my company to build an automated process for this, and the issue we recently found is that the formula I'm using strips can't return a result other than #VALUE! when the FIND formula fails to find the text I need it to.
the formula we currently have is:
=IF(FIND("-",M2,3),RIGHT(M2,2))
The cells this formula checks have states, & provinces in them which look like so "CA-ON" or "US-NV".
The problem is that regions for the UK don't fillout as "UK-XX" it inputs the actual county for example "Essex" or "Merryside"
What I need the formula to do is, if it can't find the hyphen(-) in the cell, then it should just take whatever value is there and write it in the cell the formula is in.
I should also mention that some of the cells are also blank, since this is an optional field. Is there anyway to run this formula where if it doesn't find the "-" it just writes whats there?
What about using mid() to see if the third character is "-"
=IF(MID(A1,3,1)="-",RIGHT(A1,2),A1)
If you really want to use the find() function then:
=IF(ISNUMBER(FIND("-",A1)),RIGHT(A1,2),A1)
The IFERROR Function should help here. And there isn't a reason to use the if statement anymore. The formula below will find the hyphen if it is in the first 3 characters, and find the length of the string minus the location of the hyphen and return that string. The IFERROR will catch the instances where there is no hyphen and return your original cell.
=IFERROR(RIGHT(M2,LEN(M2)-FIND("-",LEFT(M2,3),1)),M2)

ISNUMBER statement only reading first condition

Good day,
I am trying to insert this formula into excel to search for specific terms in a cell, and return a value "50" if the term is found.
I have been able to successfully implement this using the below primitive formula:
=IF(C1394<>70,C1394,IF(ISNUMBER(SEARCH("*PD*",B1394)),"50",IF(ISNUMBER(SEARCH("*OD*",B1394)),"50",IF(ISNUMBER(SEARCH("*OC*",B1394)),"50",IF(ISNUMBER(SEARCH("*OF*",B1394)),"50",IF(ISNUMBER(SEARCH("*PC*",B1394)),"50",IF(ISNUMBER(SEARCH("*MS*",B1394)),"50",C1394)))))))
I tried to make my formula more efficient and dynamic using the below approach, however excel only reads the first condition "PD" and ignores the rest
=IF(C8266 =70,IF(--ISNUMBER(SEARCH({"*PD*","*OD*","*OC*","*OF*","*PC*","*MS*"},B8266)),"50",C8266),C8266)
Can someone please advise what am I doing wrong?
You're just missing an OR clause, see this: http://www.mrexcel.com/forum/excel-questions/601195-check-multiple-text-strings-cell.html#post2977162
So you want:
=IF(C8266=70,IF(OR(ISNUMBER(SEARCH({"*PD*","*OD*","*OC*","*OF*","*PC*","*MS*"},B8266))),"50",C8266),C8266)
What you are doing wrong is you are trying to evaluate an array within a formula that doesn't usually evaluate arrays. You evaluate such formulae by pressing and holding Ctrl+Shift and then press Enter.
Otherwise, your formula can be shortened to the below:
=IF(OR(ISNUMBER((C8266=70)*SEARCH({"PD","OD","OC","OF","PC","MS"},B8266))),"50",C8266)
SEARCH does not require wildcards.
A boolean multiplied by a number gives a number. An error multiplied by a number gives an error. So you can safely combine the first and second checks together and drop the --.
OR is then used to check if there is at least 1 number within the array of numbers and/or errors.
Similarly array invoked (with Ctrl+Shift+Enter).

Find the last number in a text string

I want to find the position of the last numeric character in a text string. I'm using this formula to do so:
MAX(IF(ISERROR(FIND({1;2;3;4;5;6;7;8;9;0},A1)),"",FIND({1;2;3;4;5;6;7;8;9;0},A1))
However, this doesn't work if the string contains repeating numbers.
For instance, when the string is "10ABC2010ABC" it will return 6 instead of 9.
When the string is "10ABC2131ABN" it does return 8 instead of 9.
Any ideas what's going on?
Here is working formula:
=MAX(IF(ISNUMBER(VALUE(MID(A1,ROW(INDIRECT("1:" & LEN(A1))),1))),ROW(INDIRECT("1:" & LEN(A1)))))
press CTRL+SHIFT+ENTER to evaluate it.
Explanation:
ROW(INDIRECT("1:" & LEN(A1))) returns you array {1,2,3,...,Len(A1)}
using this array we can take each character in A1 cell: MID(A1,ROW(INDIRECT("1:" & LEN(A1))),1)
using VALUE(...) we tries to convert each character to number. It returns #VALUE! error for all characters exept 1,2,3,4,5,6,7,8,9,0
using ISNUMBER(...) we check whether VALUE(..) returns number or error, and if it returns number, we remember it's position.
final step - using Max(..) we find last position of numeric character
FIND only finds the position of the first instance of each number so it won't work for your requirements. Try using this formula
=MAX(IFERROR(FIND({1,2,3,4,5,6,7,8,9,0},A1,ROW(INDIRECT("1:"&LEN(A1)))),0))
confirmed with CTRL+SHIFT+ENTER
That also uses FIND but the ROW(INDIRECT part starts the search further along the string on each occasion. If there are no digits in A1 you get zero as the result (you could make that an error if you want)
Another possibility if you are using Excel 2010 or later is to use AGGREGATE function like this: [untested]
=AGGREGATE(14,6,FIND({1,2,3,4,5,6,7,8,9,0},A1,ROW(INDIRECT("1:"&LEN(A1)))),1)
That doesn't require "array entry"
See here for sample workbook with suggested formulas
And this array formula will also work... ok, ok... I know it uses offset :)
=1+LEN(A1)-MATCH(1;ISNUMBER(LEFT(RIGHT(A1;ROW(OFFSET(A1;0;0;LEN(A1);1))))*1)*1;0)

Resources