Checking for two values

T

Terry Freedman

Hi, sorry if this is a really easy question but it's driving me nuts
because nothing I've tried seems to work. Basically, I am looking for
a way to do this:

If cell A1 contains the word "email" and cell B1 contains "@", give
the result 1, otherwise give the result 0.

I have tried using the AND function and wildcards, but I either get an
error message or it returns an incorrect result.

Can anyone help please?

Thanks very much
Terry
 
D

Dave Peterson

One way:

=--and(countif(a1,"*email*")>0,countif(b1,"*@*")>0)

=and() will return True or False. The -- stuff changes the booleans to numbers.
 
B

Bernie Deitrick

Terry,

Basically:

=IF(AND(A1="email",B1="@"),1,0)

though it depends on your meaning of contains. The above is exact and exclusionary...this looks for
a string containing the @

=IF(AND(A1="email",NOT(ISERROR(FIND("@",B1)))),1,0)

HTH,
Bernie
MS Excel MVP
 
T

Terry Freedman

One way:

=--and(countif(a1,"*email*")>0,countif(b1,"*@*")>0)

=and() will return True or False.  The -- stuff changes the booleans to numbers.

Thank you!!! You have prevented my being carted off to an asylum. I
didn't know about -- either.
All the best
Terry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top