+ Reply to Thread
Results 1 to 11 of 11

Nested / Multiple condition statements

  1. #1
    Registered User
    Join Date
    04-14-2021
    Location
    UK
    MS-Off Ver
    Office365
    Posts
    35

    Nested / Multiple condition statements

    Hi,

    I am struggling at getting this multiple if statement working but I am not sure if the method I am using is actually correct because as soon as it hits a certain if statement line and the answer is incorrect then it is giving the false value back instead of going to the next if statement.

    I have 4 variables and the rule are:

    Variable 1: Can either be Yes or No
    Variable 2: Can either be Yes or No
    Variable 3: Can be any number
    Variable 4: Can be any number

    Rule 1: IF variable 1 is Yes AND variable 2 is Yes AND variable 3 >= variable 4 then Do something;
    Rule 2: IF variable 1 is Yes AND variable 2 is Yes AND variable 3 < variable 4 then Do something;

    Rule 3: IF variable 1 is No AND variable 2 is Yes AND variable 3 >= variable 4 then Do something;
    Rule 4: IF variable 1 is No AND variable 2 is Yes AND variable 3 < variable 4 then Do something;

    Rule 5: IF variable 1 is Yes AND variable 2 is No then Do something; (this is because if variable 2 is No then it doesnt matter what variable 3 and 4 are, so do something now)
    Rule 6: IF variable 1 is No AND variable 2 is No then Do something; (this is because if variable 2 is No then it doesnt matter what variable 3 and 4 are, so do something now)

    The way I have done this is, if v1 and v2 are both yes and if v3<v4 then do an action by outputting "rule 2 met", else output "rule 1 met"

    The same goes for the other rules but if I change the variable 2 to No then it does not meet the condition:

    HTML Code: 
    I think I am approaching this wrong, I think I need a if then elseif if its possible in excel?
    Attached Images Attached Images

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,908

    Re: Nested / Multiple condition statements

    Maybe this?
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    BSB

  3. #3
    Registered User
    Join Date
    04-14-2021
    Location
    UK
    MS-Off Ver
    Office365
    Posts
    35

    Re: Nested / Multiple condition statements

    Hi thanks so much for that it seemed to work!

    Was the issue because I was putting an expected false upon each if statement so if either of the first few lines were getting false then it would stop processing?

  4. #4
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,908

    Re: Nested / Multiple condition statements

    Yes, exactly that. When nesting IFs the "value if false" parameter should be your next IF and you only have a value if false at the end which shows if none of the other logical tests return true.

    BSB

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,069

    Re: Nested / Multiple condition statements

    Try:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I set Named Ranges for each of the variable cells so it was easier to follow the formula.

    For future reference ...

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,324

    Re: Nested / Multiple condition statements

    Yes, that was the problem: with nested IFS there is only one FALSE value right at the end.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  7. #7
    Registered User
    Join Date
    04-14-2021
    Location
    UK
    MS-Off Ver
    Office365
    Posts
    35

    Re: Nested / Multiple condition statements

    Ah ok thanks everyone for your help, I did initially think that was the problem but when I tried to edit any of my "false" values in either line then excel just through an error saying too many arguments and was hard to see where.

    I thought I did attach the file did it not come through as an image?

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,908

    Re: Nested / Multiple condition statements

    The image was there. Trevor's point was it's easier to help with a sample file than it is a picture of one.

    BSB

  9. #9
    Registered User
    Join Date
    04-14-2021
    Location
    UK
    MS-Off Ver
    Office365
    Posts
    35

    Re: Nested / Multiple condition statements

    Ah ok got you will keep that in mind for future ref. Thanks everyone will close this thread now.

  10. #10
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,908

    Re: Nested / Multiple condition statements

    No problem. Glad we could help

    BSB

  11. #11
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,069

    Re: Nested / Multiple condition statements

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ 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. [SOLVED] Multiple nested IF statements
    By Natalie C in forum Excel Formulas & Functions
    Replies: 25
    Last Post: 09-26-2021, 05:01 PM
  2. [SOLVED] Nested if statements containing multiple and statements
    By John M. in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-22-2014, 11:48 PM
  3. Nested If statements based on a true condition.
    By Jhail83 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-15-2013, 10:29 AM
  4. Multiple Nested IF Statements
    By rlsublime in forum Excel General
    Replies: 1
    Last Post: 11-15-2012, 02:01 PM
  5. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  6. Replies: 12
    Last Post: 05-15-2009, 08:38 AM
  7. Replies: 6
    Last Post: 10-31-2008, 11:52 AM

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