Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel - Need help with nested IF function

Status
Not open for further replies.

ceccoCSC

Technical User
Oct 4, 2001
16
US
Hi I'm trying to write a formula with more than 1 condition and I would like to use the OR logical operator (Example below). How would I translate it in excel?

IF cell1 <> 0 OR cell2 <> 0 then cell2/cell1 else 0

Thanks
 
Technically, if cell 2 is zero, the answer would be zero. In this case, you really only need to make sure that the denominator is <> zero for a valid result.

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

Your test has a chance to fail. For example if cell 1 is zero, the calculation Cell 2 / Cell 1 would yeild #DIV/0!
 
I know DSI has given an answer but I thought I'd give you the correct syntax for OR (or AND) statements

=IF(OR(test1,test2),TRUE,FALSE)
ie for your example:
=IF(OR(cell1 <> 0,cell2 <> 0), cell2/cell1,0)

HTH
Rgds
~Geoff~
 
You're right indeed, but I remember (because I've studied it during an excel course) that you can nest IF function and you can use the OR,AND operators in the function. I just don't remeber the exact syntax.....can you help?

Thanks
 
Thanks to both! :)
Xlbo that was exactly what I was looking for....

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top