+ Reply to Thread
Results 1 to 8 of 8

Nested if statements containing multiple and statements

  1. #1
    Registered User
    Join Date
    06-22-2014
    Location
    Peoria, AZ.
    MS-Off Ver
    2016
    Posts
    27

    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. #2
    Registered User
    Join Date
    06-22-2014
    Location
    Peoria, AZ.
    MS-Off Ver
    2016
    Posts
    27

    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. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 2000/3/7/10/13/16
    Posts
    50,749

    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),"")
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    06-22-2014
    Location
    Peoria, AZ.
    MS-Off Ver
    2016
    Posts
    27

    Re: Nested if statements containing multiple and statements

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

  5. #5
    Registered User
    Join Date
    06-22-2014
    Location
    Peoria, AZ.
    MS-Off Ver
    2016
    Posts
    27

    Re: Nested if statements containing multiple and statements

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

  6. #6
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,136

    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,""))

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 2000/3/7/10/13/16
    Posts
    50,749

    Re: Nested if statements containing multiple and statements

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

    worked fine for me??

  8. #8
    Registered User
    Join Date
    06-22-2014
    Location
    Peoria, AZ.
    MS-Off Ver
    2016
    Posts
    27

    Re: Nested if statements containing multiple and statements

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

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. questions with if statements and nested if statements
    By Pat Excel in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-03-2013, 01:41 PM
  2. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  3. Nested If statements / logic statements
    By Brainless_09 in forum Excel General
    Replies: 3
    Last Post: 06-17-2009, 02:59 PM
  4. Replies: 12
    Last Post: 05-15-2009, 08:38 AM
  5. multiple nested IF statements
    By jazzydwit in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-29-2005, 01:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1