+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    10-10-2006
    Posts
    45

    Can't find the error in this IF statement

    =IF(K154="","",
    If(AND(BI154="Hm",AC154="W",F154<0),100,if(AND(BI154="hm",AC154="W",d154>0),F154,
    if(AND(BI154="Hm",AC154="L",F154<0),F154,if(AND(BI154="hm",AC154="L",f154>0),-100,
    if(AND(BI154="aw",AC154="L",D154>0),D154,if(AND(BI154="aw",AC154="L",D154<0),100,
    if(AND(BI154="aw",AC154="W",D154<0),D154,if(AND(BI154="aw",AC154="W",D154>0),-100,
    if(AND(BI154="OT",BJ154="W"),320,-100))))))))))

    it's telling me there's an error and highlights the AND
    i went over this about 20 times and can't find anything..
    it's also almost 6am and i'm not too sharp now..
    but can anyone help with this??
    [removed].. i just can't see it..
    Last edited by DonkeyOte; 10-26-2009 at 07:02 AM. Reason: MOD: please don't use terms in ways that may offend

  2. #2
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,379

    Re: Can't find the error in this IF statement

    exceeding nested IF limitations.

    Can you confirm that the reference for Hm / W with output of F154 is definitely D154>0 and not F154 -- all other Hm references use F154
    (whereas seemingly only Aw use D154)

    I was putting together a truth table and your formulae implies:

    Code:
    BI154	AC154	F154	D154	Output
    Hm	W	<0		100
    Hm	W		>0	F154
    Hm	L	<0		F154
    Hm	L	>0		-100
    aw	L		>0	D154
    aw	L		<0	100
    aw	W		<0	D154
    aw	W		>0	-100
    Is that correct ?
    Last edited by DonkeyOte; 10-26-2009 at 07:25 AM.

  3. #3
    Registered User
    Join Date
    10-10-2006
    Posts
    45

    Re: Can't find the error in this IF statement

    Donkey.. i found the correction you noted and made it..

    HM/W and HM/L should be referring to F154...
    I have made that correction, however i still get the same error.

  4. #4
    Registered User
    Join Date
    10-10-2006
    Posts
    45

    Re: Can't find the error in this IF statement

    Is there a maximum # of IF's i can embed??

    i took the last bit out...

    if(AND(BI154="aw",AC154="W",D154>0),-100,
    if(AND(BI154="OT",BJ154="W"),320,-100))))))))))

    and it works fine..

    But i can't figure out why that last part doesn't work..

    Even if you just make it...

    if(AND(BI154="aw",AC154="W",D154>0),-100,""))))))))

    it still won't work..

  5. #5
    Forum Moderator NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003, 2007, 2010
    Posts
    31,163

    Re: Can't find the error in this IF statement

    You haven't addressed DonkeyOte's question regarding what to do if D154 and/or F154 actually equals 0?
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

  6. #6
    Valued Forum Contributor Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    Excel 2010
    Posts
    1,144

    Re: Can't find the error in this IF statement

    Taken from the help files:

    Up to seven IF functions can be nested as value_if_true and value_if_false arguments to construct more elaborate tests. (See Example 3 for a sample of nested IF functions.) If you want to test more than seven conditions, consider using the LOOKUP, VLOOKUP, or HLOOKUP function. (See Example 4 for a sample of the LOOKUP function.)

  7. #7
    Forum Moderator NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003, 2007, 2010
    Posts
    31,163

    Re: Can't find the error in this IF statement

    If you change some of those conditions to >= 0 instead of having another condition when you D or F equalling 0, then this works to cover the conditions you have imposed. (Note: I didn't change any to >= or <=, I will leave to you which to change).

    Code:
    =IF(K154="","",IF(BI154="HM",IF(AC154="W",IF(F154<0,100,F154),IF(D154<0,F154,-100)),IF(BI154,"aw",IF(AC154="L",IF(F154>0,D154,100),IF(F154<0,D154,IF(AND(BI154="OT",BJ154="W"),320,-100))))))
    you could probably use the lookup kind of table, but you added a totally outside set of variables at the end..... and not sure what else you'll change.
    Microsoft MVP - Excel

    Where there is a will there are many ways. Pick One!


    Please read the Forum Rules

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

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

    Preferred Charities: Lupus Canada and Sick Kids Foundation.
    Feel Free to Donate if you want to, for the assistance you received today.

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.2.0