If formula evaluating a string

iksotof
3StarLounger
Posts: 315
Joined: 04 May 2010, 15:18

If formula evaluating a string

Post by iksotof »

Good afternoon

i am looking for to return one of 3 values depending on another cell value. If the reference cell is populated and contains a certain string, say AB, I would like my target cell to say one thing, eg "hello", if the string doesn't contain AB then I'd like it to say Bye, if the reference has no string or entries in it I'd like my target not to populated. I am struggling a little bit with this. Can anybody please assist?


Many thanks Darren.

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: If formula evalutating a string

Post by Rudi »

This should do what you need:

=IF(A1="","",IF(A1="AB","Hello","Bye"))
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.

User avatar
HansV
Administrator
Posts: 78631
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: If formula evalutating a string

Post by HansV »

Let's say the reference cell is D5. If you want to return "hello" if D5 equals "AB":

=IF(D5="", "", IF(D5="AB", "hello", "bye"))

If you want the formula to return "hello" if the value of D5 contains "AB", possibly among other text:

=IF(D5="", "", IF(ISNUMBER(SEARCH("AB", D5)), "hello", "bye"))
Best wishes,
Hans

iksotof
3StarLounger
Posts: 315
Joined: 04 May 2010, 15:18

Re: If formula evalutating a string

Post by iksotof »

Thank you Rudi it's not quite right, I think my explanation wasn't too clear, I mean if my string contains AB, together. Ie 1234AB454545

Thanks

User avatar
Rudi
gamma jay
Posts: 25455
Joined: 17 Mar 2010, 17:33
Location: Cape Town

Re: If formula evaluating a string

Post by Rudi »

Ah... I translated, "contains a certain string" incorrectly. Apologies! You could have expressed it as, "a string contains AB".
Hans's second formula will get the job done!
Regards,
Rudi

If your absence does not affect them, your presence didn't matter.