Hello All,
I need some help looking for a function which could help me.
I have the following scenarion:
I need something similar to "IF" function. That I can use for if cell value contains part of a text value return 1 if not return 2
Example:
IF AX contains "*.*pro*.*" then BX = 1
IF AX not contain "*.*pro*.*" then BX = 2
Hope I made myself clear enough
Try this (substitute A1 with your actual cell ref)
=IF(ISNUMBER(SEARCH("*.*pro*",a1)),1,2)
Ed
_____________________________
Always learning, but never enough!
_____________________________
You could probably use either FIND() or SEARCH() (they're exactly the same, but FIND() is case sensitive but SEARCH() is not)
If you did SEARCH("Pro",A1), it would return the position of A1.
If the string does not contain the string "Pro", it will bring back an error, but use ISERROR() to trap it.
You can't use wildcard characters though, but by playing around with the SEARCH function, you should be able to get the desired result.
So something like...
IF(ISERROR(SEARCH("Pro",A1)),2,1)
Once you got that sussed, have a play with this...
There is a third argument to the SEACH() function, that is, start_number
use this third argument to locate the . areas both before & after the 'Pro' part.
thank you both for the reply will play a little bit now
Last question, how can I combine in:
IF(ISERROR(SEARCH("prov",M:M)),2,1)
more than one find text value? I want also to find blank sell + 1 additional search creteria.
Originally Posted by vladmir
Can you use 'AND'?
such as..
IF(ISERROR(AND(SEARCH("VAL1",M:M),SEARCH("VAL2",M:M))),2,1)
this will return 1 if both entries are present & correct
Try something like:
=IF(OR(ISNUMBER(SEARCH({"prov","other_word"},M1:M100))),1,2)
where other_word is your other text value to find.
Note: Since you are searching in a range, rather than only in one cell, then this becomes an array formula. You must confirm it with CTRL+SHIFT+ENTER not just ENTER. You will see { } brackets appear around the formula.
Also, unless you are on Excel2007, you cannot use whole column references such as M:M you must use a fixed range like M1:M100.
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Have you tested this?Originally Posted by aldredd
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
Nope, but yes, there is clearly something not quite right with that!Originally Posted by NBVC
Which made me realise that surely a much simpler way would be..
IF(ISERROR((SEARCH("VAL1",M:M)+SEARCH("VAL2",M:M)),2,1)
Are you certain that works?...Originally Posted by aldredd
First, of all, it must be entered as an array formula, using CTRL+SHIFT+ENTER...
Second, if you are not on 2007, you can't use M:M
Third, Each of the SEARCH() functions will return a bunch of #VALUE! errors amongst any positive finds... so the ISERROR will always yield TRUE (unless every cell in the range is filled with one of the search values....). That is why I used ISNUMBER instead... because you are looking to see if there is at least one match, not at least one error....
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
YepOriginally Posted by NBVC
I didn't need to - work as it wasFirst, of all, it must be entered as an array formula, using CTRL+SHIFT+ENTER...
hmm, I only check it aginst 1 cell, rather than a range. Probably why I got away without using arrays.Second, if you are not on 2007, you can't use M:M
hmm, depends how you read the question I think. I took it as that he wanted to check for both conditions being present, rather than one or the other, but yes, mine would not work in that case, but does for the former.Third, Each of the SEARCH() functions will return a bunch of #VALUE! errors amongst any positive finds... so the ISERROR will always yield TRUE (unless every cell in the range is filled with one of the search values....). That is why I used ISNUMBER instead... because you are looking to see if there is at least one match, not at least one error....
Even then, you could do a nested if() to check for the second criteria, Not pretty, but gets the job done
Edit: Just tried it on a range of data, and still works without using array formula, but of course, I'm looking to match both strings, rather than either of them
Again, your formula is for looking at 1 cell, not a range.... so it doesn't work on a range as the OP wants.
Microsoft MVP - Excel
Where there is a will there are many ways. Pick One!
Please read the Forum Rules
If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below
Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Preferred Charities: Lupus Canada and Sick Kids Foundation.
Feel Free to Donate if you want to, for the assistance you received today.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks