+ Reply to Thread
Results 1 to 7 of 7

help with Nested if

  1. #1
    Registered User
    Join Date
    10-28-2014
    Location
    India
    MS-Off Ver
    2010
    Posts
    3

    help with Nested if

    hi All,

    I am a new member to this forum, I am currently using following formula where I have following conditions:

    =IF(AND(BQ2="3A",BT2="Offshore",(CB2-CA2)>2000),CB2-CA2,(IF(AND(BQ2="3A",BT2="Offshore",(CB2-CA2)>=0),2000,IF(AND(BQ2="4B",BT2="Offshore",(CB2-CA2)>0,BZ2="A",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(AND(BQ2="4B",BT2="Offshore",(CB2-CA2)>0,BZ2="B",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(AND(BQ2="4A",BT2="Offshore",(CB2-CA2)>0,BZ2="A",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(AND(BQ2="4A",BT2="Offshore",(CB2-CA2)>0,BZ2="B",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(AND(BQ2="5B",BT2="Offshore",(CB2-CA2)>0,BZ2="A",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(AND(BQ2="5B",BT2="Offshore",(CB2-CA2)>0,BZ2="B",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(AND(BQ2="5A",BT2="Offshore",(CB2-CA2)>0,BZ2="A",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(AND(BQ2="5A",BT2="Offshore",(CB2-CA2)>0,BZ2="B",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,0)))))))))))

    with this formula I am getting error that I have entered too many arguments for this function. I know formula is very big but not sure where I am making error and how I can make it short.

  2. #2
    Forum Contributor
    Join Date
    04-12-2013
    Location
    Usually at work, in the UK
    MS-Off Ver
    Excel 2010
    Posts
    639

    Re: help with Nested if

    For a start these are the same, greater than 0 & greater than 2000 (same thing). Plus aren't you only allowed a certain number of conditions (7 or 9 I think) does this exceed that limit (count the IF's).
    Please Login or Register  to view this content.
    This is mid formula and has a true and a false result, I would guess this is your problem.
    Please Login or Register  to view this content.
    I gave up after this, I think that's enough to get you going

  3. #3
    Registered User
    Join Date
    10-28-2014
    Location
    India
    MS-Off Ver
    2010
    Posts
    3

    Re: help with Nested if

    I in first error that you pointed out, I wanted to say do treatment only if value is greater then or equal to 0 and not if it is negative.

  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,939

    Re: help with Nested if

    richa, welcome to the forum

    I think that the way I would handle this would be to 1st, use a helper to combine BQ2 and BT2, although you are testing for BT2="Offshore" in every test, so you could eliminate that from the all teh AND()'s you have and put it in once at the start.

    You would then start with...
    =IF(BT2="Offshore",IF(

    As for the rest, it's entirely possible that I am missing something, but these look identical, except for the test for A or B?
    AND(BQ2="4B",(CB2-CA2)>0,BZ2="A",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(
    AND(BQ2="4B",(CB2-CA2)>0,BZ2="B",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(

    What exactly are you trying to do here, can you provide a sample workbook?
    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
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,649

    Re: help with Nested if

    What I have observed roughly from your formula is this.....

    In nested IFs, the inner IF begins within the FALSE of the outer IF statement. So when a normal IF statement would be like this.....

    =IF(logical_test,"Do this if logical test is found True","else do this if logical test is false")

    And with a nested if it would be like this......

    =IF(logical_test,"Do this if logical test is found True",
    IF(logical_test,"Do this if logical test is found True","else do this if logical test is false"))

    Now in your nested if formula, you have IF statements like this.....

    =IF(AND(BQ2="4B",(CB2-CA2)>0,BZ2="A",(CB2-CA2)>CA2*7%),CB2-CA2,CA*7%,IF(

    Here blue is the logical test, green is for True and brown is for False, so your IF statement is completed and there is no room or scope for another nested IF statement.

    Enter your formula in the formula cell, hit enter and after getting an error of too many arguments click ok and now click in the formula bar in the beginning of your formula and with the help of right arrow key go through the formula and notice the formula syntax pop up help to know where exactly you are in the formula. That will help you to correct the formula.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  6. #6
    Registered User
    Join Date
    10-28-2014
    Location
    India
    MS-Off Ver
    2010
    Posts
    3

    Re: help with Nested if

    Sample.xlsx hi ford please find attached sample file

  7. #7
    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,939

    Re: help with Nested if

    Looking at your WB, I take it this is an abbreviated version of your original file? Your formula refers to BT2, but your table only goes as far as AJ?
    Also, your references to columns like CB2-CA2 and BQ2, make it almost impossible for me to try and figure out what you are trying to do here

    Can you either fix the references in your formula, to relate to your workbook, or walk me though what you are trying to do?

+ 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] Nested Sumif's or how to sum data based on nested criteria
    By dlietz in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-07-2014, 11:36 AM
  2. How to reduces Nested IF code(144 Nested IF) to achive same functionality
    By jobseeker in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2014, 09:45 AM
  3. Replies: 0
    Last Post: 10-01-2012, 05:54 AM
  4. For each loop nested; getting stuck on one cell in first iteration of nested loop
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-22-2009, 11:54 AM
  5. help on a nested countif/nested if formula
    By vickiemc in forum Excel General
    Replies: 2
    Last Post: 08-13-2008, 08:29 AM

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