Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can i chek if one value (e.g the string in A2) contains other value (e.g the string in B3)?

share|improve this question
add comment

migrated from stackoverflow.com Mar 17 '11 at 13:00

This question came from our site for professional and enthusiast programmers.

2 Answers

up vote 2 down vote accepted
=IF(ISERROR(FIND(B3,A2)),"it's not there","it's there")

FIND returns the position in A2 where B3 is found, or #VALUE if it's not found.

ISERROR tests for #VALUE

share|improve this answer
    
thanks! it almost what i wanted. i managed to do this like this: =IF(ISERR(FIND(A2,B2)=TRUE,1,0) –  aharon Mar 17 '11 at 12:27
    
it would be nice to get at least an upvote for that... –  tenfour Mar 17 '11 at 13:00
    
You got an upvote from me! ISERR is slightly better than ISERROR here as it excludes the case where B3 or A2 contain a #N/A themselves (small possibility, but better to exclude any cases we don't need to consider). @aharon: There is no need to do the =TRUE bit, simply ISERR(FIND(foo, bar)) will evaluate to TRUE or FALSE, so testing if TRUE=TRUE is not helpful. –  AdamV Mar 21 '11 at 10:48
add comment

You can use the FIND() function; it returns the index of string1 in string2 if it exists, or error otherwise.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.