+ Reply to Thread
Results 1 to 12 of 12

How to nest two IF statements

  1. #1
    Registered User
    Join Date
    01-14-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    27

    Question How to nest two IF statements

    How can I combine these two statements into one formula?


    =IF(AND(B24=1,C24=10),C24,-5)

    =IF(AND(B24=1,C24=-10),C24,"")

    Thanks

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: How to nest two IF statements

    Try:

    =IF(B24=1,IF(ABS(C24)=10,C24,-5),"")
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: How to nest two IF statements

    Try this one.

    Please Login or Register  to view this content.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: How to nest two IF statements

    Hi wolfgang and welcome to the forum

    Im sorry, but the logic of what you are trying to do, escapes me. just for now, lets ignore the B24=1 part, its the same in both
    the 1st formula you test for C24=10 - if true, return C24
    the 2nd formula you test for C24=-10 - if true, return C24
    so, so far you are returning the same value for a true in both.

    now to the 2nd part of each forumla...
    1st formula...if C24 is not 10 then give -5
    2nd formula...if C24 is not -10 then give ""

    so my question is, if C24 is, say, 7...what result would you expect?

    based on the 1st formula, C24 is not = 10, so the answer would be -5
    but based on the 2nd formula, C24 is not = -10 so the answer would be ""

    so........??
    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

  5. #5
    Registered User
    Join Date
    01-14-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: How to nest two IF statements

    Hope this is clearer:

    Condition , Result if true , Else
    B24=1 and C24= 10 , D24= 10 , -5 (i.e., for any B24 <> 1 -- e.g., B24=0)
    B24=1 and C24= -10 , D24= -10 , "" (i.e., for any B24 <> 1 -- e.g., B24=0)
    Last edited by wolfgang713; 01-14-2013 at 05:39 PM.

  6. #6
    Registered User
    Join Date
    01-14-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: How to nest two IF statements

    This works for all conditions except B24=0 and C24=10 -- expect -5

  7. #7
    Registered User
    Join Date
    01-14-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: How to nest two IF statements

    (replied to another post -- sorry)

  8. #8
    Registered User
    Join Date
    01-14-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: How to nest two IF statements

    oeldere: Thanks. This works for all conditions except B24=0 and C24=10 -- expect -5

  9. #9
    Registered User
    Join Date
    01-14-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    27

    Re: How to nest two IF statements

    Hope this is clearer:

    Condition Result if true Else
    B24=1 and C24= 10 D24= 10 -5 (i.e., for any B24 <> 1 -- e.g., B24=0)
    B24=1 and C24= -10 D24= -10 "" (i.e., for any B24 <> 1 -- e.g., B24=0)

  10. #10
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: How to nest two IF statements

    self deleted
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: How to nest two IF statements

    Try:

    =IF(C24=10,IF(B24=1,C24,-5),IF(C24=-10,IF(B24=1,C24,""),""))

  12. #12
    Registered User
    Join Date
    01-14-2013
    Location
    New York
    MS-Off Ver
    Excel 2007
    Posts
    27

    Smile Re: How to nest two IF statements

    [QUOTE=NBVC;3082678]Try:

    =IF(C24=10,IF(B24=1,C24,-5),IF(C24=-10,IF(B24=1,C24,""),""))

    This works perfectly. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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