+ Reply to Thread
Results 1 to 9 of 9

Excel 2007 : multiple nested if

  1. #1
    Registered User
    Join Date
    09-12-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007, Excel 2010, Excel 2013
    Posts
    31

    multiple nested if

    Hi All,

    I have the spreadsheet like this:

    B6: dropdown list with PH/SUN
    C6: Dropdown list with NIGHT
    D6: Dropdown list with LATE
    E6: total boxes
    F6: total amount
    If night (C6) and late(D6) then boxes(E6) * 7, if (c6) blank and late(D6) then boxes (e6*7)
    if night (C6) then boxes(E6) * 7.5 other than that E6*7.
    G6: if night and late G6 = blank or 0
    G6: if day and late G6 = blank or 0
    G6: if night only = blank
    G6 if day then check the boxes if more than 13,then boxes-13 * 0.5

    in F6 : total amount:
    =IF(ISTEXT(C6),E6*7.5,IF(AND(ISTEXT(C6),ISTEXT(D6),(E6*7),),IF(OR(ISTEXT(C6)),ISTEXT(D6),ISTEXT((E6* 7)))))

    it seems that the formula only refer to night and late, doesn't applicable to day and late.

    Please help.

    thanks a lot
    Last edited by onestar; 09-26-2011 at 12:10 AM.

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: multiple nested if

    Maybe this in F6: =E6*7+IF(AND(C6="Night",D6<>"Late"),E6/2,0)
    And this in G6: =IF(D6="Late","",IF(E6>13,(C6="Day")*E6/2))

  3. #3
    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
    44,447

    Re: multiple nested if

    If I just put that formula into cell F6 on an otherwise blank row, it returns FALSE.

    I'm guessing there should be another part that is missing?

    You also have an extra comma that seems to do no harm but serves no purpose:

    =IF(ISTEXT(C6),E6*7.5,IF(AND(ISTEXT(C6),ISTEXT(D6),(E6*7),),IF(OR(ISTEXT(C6)),ISTEXT(D6),ISTEXT((E6* 7)))))
    should be:

    =IF(ISTEXT(C6),E6*7.5,IF(AND(ISTEXT(C6),ISTEXT(D6),(E6*7)),IF(OR(ISTEXT(C6)),ISTEXT(D6),ISTEXT((E6* 7)))))

    Breaking down the formula:

    =IF(
    ...(condition) ISTEXT(C6),
    ...(True Result) E6*7.5,
    ...(False Result) IF(
    ......(condition) AND(ISTEXT(C6),ISTEXT(D6),(E6*7)),
    ......(True Result) IF(
    .........(condition) OR(ISTEXT(C6)),
    .........(True Result) ISTEXT(D6),
    .........(False Result) ISTEXT((E6* 7)))))

    Somewhere along the line, you're missing a FALSE result ... but I'm not sure how to rearrange the brackets.

    This: AND(ISTEXT(C6),ISTEXT(D6),(E6*7)) looks wrong as you're ANDing E6*7 which looks as though it should be a result. Maybe: AND(ISTEXT(C6),ISTEXT(D6)),E6*7, ...

    This: ISTEXT((E6* 7) also looks wrong as E6*7 should be a value and, therefore, not TEXT.

    However, going on your description of the formula, maybe this will work for you:

    =IF(AND(C6<>"",D6<>""),E6*7,IF(AND(C6="",D6<>""),E6*7,IF(C6<>"",E6*7.5,E6*7)))


    Regards
    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


  4. #4
    Registered User
    Join Date
    09-12-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007, Excel 2010, Excel 2013
    Posts
    31

    Re: multiple nested if

    Thanks TMShucks for your quick response.
    It's perfect.I think I'm too focus on istext instead.
    Will try to calculate the G6 and will reply to this forum again.

  5. #5
    Registered User
    Join Date
    09-12-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007, Excel 2010, Excel 2013
    Posts
    31

    Re: multiple nested if

    Thanks zbor,

    for C6 i only put "NIGHT" in drop down list, and 0.5 is not equal with /2. 0.5 * total boxes if more than 13.

  6. #6
    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
    44,447

    Re: multiple nested if

    You're welcome.

  7. #7
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,602

    Re: multiple nested if

    Quote Originally Posted by onestar View Post
    and 0.5 is not equal with /2.
    that's something new

  8. #8
    Registered User
    Join Date
    09-12-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007, Excel 2010, Excel 2013
    Posts
    31

    Re: multiple nested if

    Hi TMShucks,

    I don't know why, my reply didn't appear in here, anyway, I try to create the formula for G6, but it's return FALSE if boxes less than 13
    G6 =IF(AND(C6="",D6=""),IF(E6>13,(E6-13)*0.5),"")

    and for H6 condition: if NIGHT/DAY AND LATE no additional 5$, but if NIGHT AND DAY get 5$.
    I have create the rule like this
    H6 =IF(AND(C6<>"",D6<>""),5,"")

    Please advise if there's something missing in this formula.
    Thanks

  9. #9
    Registered User
    Join Date
    09-12-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2007, Excel 2010, Excel 2013
    Posts
    31

    Re: multiple nested if

    revision for H6

    =IF(AND(C6="",D6=""),5,(IF(AND(C6<>"",D6=""),5,"")))

+ 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