Syntax HELP

E

Eric H

I know this is wrong...
=if(G40>0,G40*$G$36,""),or(if(I40>0,I40*$I$36,"")or(if(K40>0,K40*K36,"")


but what is the correct way to write an IF,OR statement?
 
F

Fred Smith

It doesn't look to me like you want an Or condition. You want nested Ifs, as
in:
=if(G40>0,G40*$G$36,if(I40>0,I40*$I$36,if(K40>0,K40*K36,"")))

Regards,
Fred.
 
D

Don Guillett

Depends on what you want. This checks g40 and if >0,g40*g36. If not then
checks i40 and then checks k40.
Is this what you want?
=IF(G40>0,G40*G36,IF(I40>0,I40*I36,IF(K40>0,K40*K36,"")))
 
S

smartin

Eric said:
I know this is wrong...
=if(G40>0,G40*$G$36,""),or(if(I40>0,I40*$I$36,"")or(if(K40>0,K40*K36,"")


but what is the correct way to write an IF,OR statement?

Hi Eric,

Well, the way to do OR is a little backwards in my opinion, but it goes
like this:

=OR(condition 1, condition 2, etc...)

This will return TRUE or FALSE.

But I don't think that's what you are trying to do. So forget about OR
for now.

IF can be used to make choices, like "IF..ELSEIF" by nesting. The
general form of IF is

=IF(condition, value if TRUE, value if FALSE)

This can be expanded to make choices as follows:

=IF(condition 1, value if true, IF(condition 2, value if true,
IF(condition 3, value if true, default value)))

You can nest IF like this for a few levels. I don't recall how many
because I seldom do this (it gets quite tricky to edit and maintain
after 2 or three levels).

I leave it to you to think about your formula, but here are some hints.
You are making three tests (G40>0, etc.) How are these prioritized? The
highest priority decision goes in the first condition of your nested IF.
 
Top