user2051347
user2051347

Reputation: 1669

Comparing two string values with an if statement

I am using excel 2010 and want to give out 1 if it's true and 0 if it's false for a given string.

I tried:

=IF((EXACT(G2;"V") OR EXACT(G2;"K"));"1";"0")

However, this always gives me an error.What's wrong with this formula?

I appreciate your replies!

Upvotes: 0

Views: 3614

Answers (1)

Jerry
Jerry

Reputation: 71538

That's not how you use the OR formula. Try this:

=IF(OR(EXACT(G2;"V");EXACT(G2;"K"));"1";"0")

It is indeed:

OR(Test; Test; Test; ...)

Note:

  1. I'm not sure why you used "1" and "0", but you can drop the quotes if you don't mind having numbers.

  2. You might also simply use:

    =OR(EXACT(G2;"V");EXACT(G2;"K"))
    

To get the result as TRUE or FALSE, or if you want to get 1 or 0...

=OR(EXACT(G2;"V");EXACT(G2;"K"))*1

Upvotes: 2

Related Questions