ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   nested if statements (https://www.excelbanter.com/excel-worksheet-functions/110070-nested-if-statements.html)

Jeremy

nested if statements
 
Here's the situation: I'm trying to return a specific value to the cell based
on conditions in 4 cells in the same row. If A is valid (in this case1966),
then I want to check B to see if that has a valid value (also 1966). If both
these conditions are true, then I want to check to see whether A and B agree.
If all 3 things are true, then I want to see a value of 1. If the first 2 are
true (A and B are both valid) but the 3rd is not (A is not equal to B), then
the value in the cell should be equal to (A-B)+1.

If the first condition is true (A 1966), but the 2nd is not, I want to
return a value of 1.

If the first condition (A1966) is false, then I want to check B for a
valid value (1966). If B is valid, then I want to return a value of 1. If
not, then I want to check C for validity. If C is valid (1966), then I want
to return a value of C-D. If it is not, then I'd like to return a value of
2007-D.

This is the formula I use:

IF(A11966,if(b11966,if(a1=b1,1(a1-b1+1),1,IF(B11966,1,IF(C11966,(C1-D1)+1,2007-D1)))

I get "The formula you typed contains an error". I can't figure out the error.

Any help will be greatly appreciated.


lk

nested if statements
 
I think it is this part that is causing your problem:

if(a1=b1,1(a1-b1+1)

maybe you need a comma between the first "1" and the (a1-b1+1)

"Jeremy" wrote:

Here's the situation: I'm trying to return a specific value to the cell based
on conditions in 4 cells in the same row. If A is valid (in this case1966),
then I want to check B to see if that has a valid value (also 1966). If both
these conditions are true, then I want to check to see whether A and B agree.
If all 3 things are true, then I want to see a value of 1. If the first 2 are
true (A and B are both valid) but the 3rd is not (A is not equal to B), then
the value in the cell should be equal to (A-B)+1.

If the first condition is true (A 1966), but the 2nd is not, I want to
return a value of 1.

If the first condition (A1966) is false, then I want to check B for a
valid value (1966). If B is valid, then I want to return a value of 1. If
not, then I want to check C for validity. If C is valid (1966), then I want
to return a value of C-D. If it is not, then I'd like to return a value of
2007-D.

This is the formula I use:

IF(A11966,if(b11966,if(a1=b1,1(a1-b1+1),1,IF(B11966,1,IF(C11966,(C1-D1)+1,2007-D1)))

I get "The formula you typed contains an error". I can't figure out the error.

Any help will be greatly appreciated.


bj

nested if statements
 
IF(A11966,if(b11966,if(a1=b1,1(a1-b1+1),1,IF(B11966,1,IF(C11966,(C1-D1)+1,2007-D1)))

IF(and(A11966,B11966),if(a1=b1,1,a1-b1+1),IF(and(A1<=1966,B11966),1,IF(C11966,C1-D1,2007-D1)))





"Jeremy" wrote:

Here's the situation: I'm trying to return a specific value to the cell based
on conditions in 4 cells in the same row. If A is valid (in this case1966),
then I want to check B to see if that has a valid value (also 1966). If both
these conditions are true, then I want to check to see whether A and B agree.
If all 3 things are true, then I want to see a value of 1. If the first 2 are
true (A and B are both valid) but the 3rd is not (A is not equal to B), then
the value in the cell should be equal to (A-B)+1.

If the first condition is true (A 1966), but the 2nd is not, I want to
return a value of 1.

If the first condition (A1966) is false, then I want to check B for a
valid value (1966). If B is valid, then I want to return a value of 1. If
not, then I want to check C for validity. If C is valid (1966), then I want
to return a value of C-D. If it is not, then I'd like to return a value of
2007-D.

This is the formula I use:

IF(A11966,if(b11966,if(a1=b1,1(a1-b1+1),1,IF(B11966,1,IF(C11966,(C1-D1)+1,2007-D1)))

I get "The formula you typed contains an error". I can't figure out the error.

Any help will be greatly appreciated.



All times are GMT +1. The time now is 09:44 AM.

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