ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   IF statement syntax (https://www.excelbanter.com/excel-discussion-misc-queries/236815-if-statement-syntax.html)

Sander

IF statement syntax
 
What is the proper syntax for a non-nested, two-condition IF statement?

Example: IF(C16<1 & C151,-B15).

This syntax appears to work when the two elements of the condition are
simultaneously true. Unfortunately, -B15 is apparently always returned, even
when the two conditions are not simultaneously true. What up? How do I get
this right?

Thanks.

joeu2004

IF statement syntax
 
"Sander" wrote:
Example: IF(C16<1 & C151,-B15).


That should be written:

=if(and(C16<1, C151), -B15, "")

Note that I added "" to cover the case when the condition is not met. You
might replace "" with something else. But if you omit that part, the IF
function will return FALSE, which is usually undesirable.


----- original message -----

"Sander" wrote in message
...
What is the proper syntax for a non-nested, two-condition IF statement?

Example: IF(C16<1 & C151,-B15).

This syntax appears to work when the two elements of the condition are
simultaneously true. Unfortunately, -B15 is apparently always returned,
even
when the two conditions are not simultaneously true. What up? How do I
get
this right?

Thanks.



Jacob Skaria

IF statement syntax
 
If true -B15 if false blank

=IF(AND(C16<1,C151),-B15,"")

If this post helps click Yes
---------------
Jacob Skaria


"Sander" wrote:

What is the proper syntax for a non-nested, two-condition IF statement?

Example: IF(C16<1 & C151,-B15).

This syntax appears to work when the two elements of the condition are
simultaneously true. Unfortunately, -B15 is apparently always returned, even
when the two conditions are not simultaneously true. What up? How do I get
this right?

Thanks.


David Biddulph[_2_]

IF statement syntax
 
=IF(AND(C16<1,C151),-B15,"whatever answer you want if your condition isn't
met")
--
David Biddulph

"Sander" wrote in message
...
What is the proper syntax for a non-nested, two-condition IF statement?

Example: IF(C16<1 & C151,-B15).

This syntax appears to work when the two elements of the condition are
simultaneously true. Unfortunately, -B15 is apparently always returned,
even
when the two conditions are not simultaneously true. What up? How do I
get
this right?

Thanks.




T. Valko

IF statement syntax
 
Try it like this:

=IF(AND(C16<1,C151),-B15,"")

If C16 is an empty cell it will evaluate to be less than 1. If you don't
what that to happen:

=IF(AND(C16<"",C16<1,C151),-B15,"")


--
Biff
Microsoft Excel MVP


"Sander" wrote in message
...
What is the proper syntax for a non-nested, two-condition IF statement?

Example: IF(C16<1 & C151,-B15).

This syntax appears to work when the two elements of the condition are
simultaneously true. Unfortunately, -B15 is apparently always returned,
even
when the two conditions are not simultaneously true. What up? How do I
get
this right?

Thanks.





All times are GMT +1. The time now is 12:45 PM.

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