ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Using IF and OR (https://www.excelbanter.com/excel-discussion-misc-queries/174115-using-if.html)

Dustin B[_2_]

Using IF and OR
 
I am trying to use if and or statement together and cannot get the syntax
right. I know I must be missing something quite obvious here. What I am
trying to do is mark a cell with a 0 or 1 if cell K2 =
11,or13,or14,or17,or18,or20,or21,or23. Can someone throw me a bone on this
one? The help file in exel does not show syntax for using if and or together
and I guess that is what I am messing up.

Thanks.



Dave Peterson

Using IF and OR
 
One way:
=if(OR(K2={11,13,14,17,18,20,21,23}),1,0)

Another way without the =if()

=--OR(K2={11,13,14,17,18,20,21,23})

The =or() function returns True or False. The first - sign converts false to 0
and true to -1. The second - sign doesn't change the 0, and converts the -1 to
+1.



Dustin B wrote:

I am trying to use if and or statement together and cannot get the syntax
right. I know I must be missing something quite obvious here. What I am
trying to do is mark a cell with a 0 or 1 if cell K2 =
11,or13,or14,or17,or18,or20,or21,or23. Can someone throw me a bone on this
one? The help file in exel does not show syntax for using if and or together
and I guess that is what I am messing up.

Thanks.


--

Dave Peterson

David Biddulph[_2_]

Using IF and OR
 
It's easy enough, in that the condition test in the IF statement might
either be a simple test, such as K2=11, or it can be any other formula which
returns a TRUE or FALSE, so you merely replace the test by the OR function.
=IF(OR(K2=11,K2=13,K2=14,K2=17,K2=18,K2=20,K2=21,K 2=23),1,0)

You can shorten this to =IF(OR(K2={11,13,14,17,18,20,21,23}),1,0)
and because TRUE and FALSE are evaluated as 1 and 0 respectively you can
omit the IF and use
=--OR(K2={11,13,14,17,18,20,21,23})
where the double unary minus before the OR coerces the TRUE or FALSE to a
numerical value.
--
David Biddulph

"Dustin B" <Dustin wrote in message
...
I am trying to use if and or statement together and cannot get the syntax
right. I know I must be missing something quite obvious here. What I am
trying to do is mark a cell with a 0 or 1 if cell K2 =
11,or13,or14,or17,or18,or20,or21,or23. Can someone throw me a bone on
this
one? The help file in exel does not show syntax for using if and or
together
and I guess that is what I am messing up.

Thanks.






All times are GMT +1. The time now is 11:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com