IF, THEN

G

Gale Gorman

I would like to embed an "if" statement in a cell but don't
know the syntax.

My example is from D1 write the following:

(if (A1 > 0)(A1 / C1) (if (B1 > 0)(B1 / C1)))

I am assuming that if the first "IF" fails, the "THEN" part
will go to the next "IF" statement.

Thanks in advance,

Gale Gorman
Houston
 
J

John Wilson

Gale,

The following should work for the example that you gave:
=IF(A1>0,A1/C1,IF(B1>0,B1/C1,"neither"))

Basic construct of the IF statement:
=IF("condition","true",false")
In the case above, you substitute the "false" with another complete
IF statement.

Keep in mind that it works in order so if A1 is greater than 0,
it'll never look to see what's in B1.

Also, if there's nothing in C1, you'll get a DIV#0 error.
To cure this, you could embed yet another IF statement:
=IF(C1=0,"C1 is Zero",IF(A1>0,A1/C1,IF(B1>0,B1/C1,"neither")))
Substitute what's in qutes above with whatever suits your needs.

John
 
K

KAB1400

=IF(A1>0,(A1/C1),IF(B1>0,(B1/C1),0))

the comma after the >0 can be read as the "then".
 

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