# Nested if statements containing multiple and statements

1. ## Nested if statements containing multiple and statements

I am having a hard time getting a nested if statement containing multiple and statements as listed below;

a1=7
a2=9

What i am looking for is;
If a1 is less than 15 and a2 is reater than 3 then give answer of 1
if a1 is less than 15 and a2 is greater than 5 then give answer of 2

Here is what i tried with no luck..

If(AND(a1<15,a2>3),1, if(and(a1,15,a2>5),2))

Can anybody help me with this?

2. ## Re: Nested if statements containing multiple and statements

made a slight mistake in previous post...here is the corrected version of what i have tried with no luch...

If(AND(a1<15,a2>3),1, if(and(a1<15,a2>5),2))

3. ## Re: Nested if statements containing multiple and statements

Hi and welcome to the forum

What i am looking for is;
If a1 is less than 15 and a2 is reater than 3 then give answer of 1
if a1 is less than 15 and a2 is greater than 5 then give answer of 2
=if(A1<15,if(A2>5,2,1),"")

You did not say what to do is A1 >15, so I used ""

edit: Not that I would advocate doing it this way, but to correct how you were trying to do it...
If(AND(a1<15,a2>5),2, if(and(a1<15,a2>3),1),"")

4. ## Re: Nested if statements containing multiple and statements

This says there are too many arguments... still not working.

5. ## Re: Nested if statements containing multiple and statements

i will copy the actual spreadsheet later this eve... Thanks for the help.

6. ## Re: Nested if statements containing multiple and statements

welcome to the forum, John M. you can use the 1st formula provided by FDibbins. that should work for you. the 2nd formula he advised on correcting your formula should be:
=IF(AND(A1<15,A2>5),2,IF(AND(A1<15,A2>3),1,""))

7. ## Re: Nested if statements containing multiple and statements

Originally Posted by John M.
This says there are too many arguments... still not working.
=if(A1<15,if(A2>5,2,1),"")

worked fine for me??

8. ## Re: Nested if statements containing multiple and statements

Thanks to both Ford and benishiryo - that did the trick - you guys are awesome!

There are currently 1 users browsing this thread. (0 members and 1 guests)