ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   How do I set up a formula with multiple conditions? (https://www.excelbanter.com/excel-discussion-misc-queries/29944-how-do-i-set-up-formula-multiple-conditions.html)

Fred Borden

How do I set up a formula with multiple conditions?
 
I need to know how to develop a formula that will look at "x" "y" and see if
either is between both "a" and "b" ie.:

x=d2
y=d6
a=a12
b=b12

If(d2a12 and d6<b12,d6-d2,0)



Jason Morin

This formula tests D2 first, then D6. So even if D6 satisfies both
conditions, it will still read "D2 is between both" if D2 satisfies both
conditions:

=IF(AND(D2A12,D2<B12),"D2 is between both",IF(AND(D6A12,D6<B12),"D6 is
between both","Both tests failed"))

Or maybe you're looking for something like:

=IF(OR(AND(D2A12,D2<B12),AND(D6A12,D6<B12)),"D2 and/or D6 are between
both","D2 and D6 both failed")

HTH
Jason
Atlanta, GA


"Fred Borden" wrote:

I need to know how to develop a formula that will look at "x" "y" and see if
either is between both "a" and "b" ie.:

x=d2
y=d6
a=a12
b=b12

If(d2a12 and d6<b12,d6-d2,0)



JR

=+IF(D2A12,IF(D2<B12,IF(D6A12,IF(D6<B12,C1-B1,0))))
Fred: This will work. It's called an embedded if statement. You a just
using four ifs all together. Just remember for every open parenthesis, you
must have a close parenthesis.

"Fred Borden" wrote:

I need to know how to develop a formula that will look at "x" "y" and see if
either is between both "a" and "b" ie.:

x=d2
y=d6
a=a12
b=b12

If(d2a12 and d6<b12,d6-d2,0)



Fred Borden

Jason, thanks for your help!

"Jason Morin" wrote:

This formula tests D2 first, then D6. So even if D6 satisfies both
conditions, it will still read "D2 is between both" if D2 satisfies both
conditions:

=IF(AND(D2A12,D2<B12),"D2 is between both",IF(AND(D6A12,D6<B12),"D6 is
between both","Both tests failed"))

Or maybe you're looking for something like:

=IF(OR(AND(D2A12,D2<B12),AND(D6A12,D6<B12)),"D2 and/or D6 are between
both","D2 and D6 both failed")

HTH
Jason
Atlanta, GA


"Fred Borden" wrote:

I need to know how to develop a formula that will look at "x" "y" and see if
either is between both "a" and "b" ie.:

x=d2
y=d6
a=a12
b=b12

If(d2a12 and d6<b12,d6-d2,0)




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

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