+ Reply to Thread
Results 1 to 11 of 11

Macro for Nested IF - Too Many Arguments

  1. #1
    Registered User
    Join Date
    09-14-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    67

    Macro for Nested IF - Too Many Arguments

    Good evening,

    I'm trying a nested if function but getting the error message that I have too many arguments. The formula is as follows

    =IFERROR(IF(AND(H2>=1, H2<=7), B2*150, C2*110, D2*90, E2*75,F2*60, G2*60, IF(H2=8, B2*170, C2*125, D2*100, E2*85,F2*65,G2*60, IF(H2=9, B2*180, C2*135, D2*110,E2*90, F2*70,G2*60, IF(H2=10, B2*190, C2*145, D2*115, E2*95,F2*75,G2*60, IF(AND(H2>=11,H2<=20), B2*210, C2*160, D2*125, E2*105,F2*85,G2*60, IF(AND(H2>=21, H2<=22), B2*230, C2*175, D2*140, E2*115,F2*90,G2*60, IF(AND(H2>=23, H2<=24),B2*255, C2*190, D2*155, E2*125,F2*100,G2*60, IF(AND(H2>=25, H2<=26), B2*275, C2*205, D2*165, E2*135,F2*110, G2*60, IF(AND(H2>=27, H2<=28), B2*300, C2*225, D2*180, E2*150,F2*120,G2*60, IF(AND(H2>=29, H2<=30), B2*320, C2*240, D2*190, E2*160,F2*130, G2*60, IF(AND(H2>=31, H2<=32), B2*345, C2*260, D2*205, E2*170,F2*140, G2*60, IF(AND(H2>=33, H2<=34), B2*370, C2*275, D2*220, E2*185,F2*150, G2*60, IF(AND(H2>=35, H2<=36), B2*390, C2*290, D2*235, E2*195,F2*155, G2*60, IF(AND(H2>=37, H2<=38), B2*460, C2*345, D2*275, E2*230,F2*185, G2*60, IF(AND(H2>=39, H2<=50), B2*485, C2*365, D2*290, E2*240,F2*195, G2*60),0)


    What are my alternatives to this if function. I'm assuming a Macro VBA is my best bet. Any assistance would be great appreciated

  2. #2
    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,364

    Re: Macro for Nested IF - Too Many Arguments

    The structure of an IF function is =IF(Condition, result if True, result if False) and a simple nested IF function is =IF(Condition 1, result if True, IF(Condition 2, result if True, result if False)). You can build on that ... =IF(Condition 1, result if True, IF(Condition 2, result if True, IF(Condition 3, result if True, result if False))) and so on.

    That isn't what you have ... even with the AND.
    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


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

    Re: Macro for Nested IF - Too Many Arguments

    This
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    part constitutes six (6) results where there should only be one (1).

  4. #4
    Registered User
    Join Date
    09-14-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    67

    Re: Macro for Nested IF - Too Many Arguments

    What are my alternatives?

  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
    44,364

    Re: Macro for Nested IF - Too Many Arguments

    No idea. What are you trying to do?


    Attach a sample workbook (not a picture or pasted copy). Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  6. #6
    Registered User
    Join Date
    09-14-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    67

    Re: Macro for Nested IF - Too Many Arguments

    I'm trying to determine commissions based on the picture snapshot of comp doc except the last column is HSD Only instead of Previous Period Lead Connect. I was using the if statements because the multipliers change based on total connects. There is a before and after in the 'Sample Commissions' document
    Attached Images Attached Images
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    09-14-2013
    Location
    Columbia, SC
    MS-Off Ver
    Excel 2010
    Posts
    67

    Re: Macro for Nested IF - Too Many Arguments

    I see my mistake. My statement should actually show as follows but I'm still receiving the too many arguments error.

    =IFERROR(IF(AND(H2>=1, H2<=7), ((B2*150)+ (C2*110)+ (D2*90)+( E2*75)+(F2*60)+(G2*60)), IF(H2=8, ((B2*170)+(C2*125)+(D2*100)+(E2*85)+(F2*65)+(G2*60)), IF(H2=9, ((B2*180)+(C2*135)+ (D2*110)+(E2*90)+(F2*70)+(G2*60)), IF(H2=10, ((B2*190)+ (C2*145)+ (D2*115)+ (E2*95) +(F2*75)+(G2*60)), IF(AND(H2>=11,H2<=20), ((B2*210)+ (C2*160)+ (D2*125)+ (E2*105)+(F2*85)+(G2*60)), IF(AND(H2>=21, H2<=22), ((B2*230)+ (C2*175)+ (D2*140)+(E2*115)+(F2*90)+(G2*60)), IF(AND(H2>=23, H2<=24),((B2*255)+ (C2*190)+ (D2*155)+ (E2*125)+(F2*100)+(G2*60)), IF(AND(H2>=25, H2<=26), ((B2*275)+ (C2*205)+ (D2*165)+ (E2*135)+(F2*110)+ (G2*60)), IF(AND(H2>=27, H2<=28), ((B2*300)+ (C2*225)+ (D2*180)+ (E2*150)+(F2*120)+(G2*60)), IF(AND(H2>=29, H2<=30), ((B2*320)+ (C2*240)+ (D2*190)+ (E2*160)+(F2*130)+ (G2*60)), IF(AND(H2>=31, H2<=32), ((B2*345)+ (C2*260)+ (D2*205)+ (E2*170)+(F2*140)+ (G2*60)), IF(AND(H2>=33, H2<=34), ((B2*370)+ (C2*275)+(D2*220)+(E2*185)+(F2*150)+ (G2*60)), IF(AND(H2>=35, H2<=36), ((B2*390)+ (C2*290)+ (D2*235)+ (E2*195)+(F2*155)+(G2*60)), IF(AND(H2>=37, H2<=38), ((B2*460)+(C2*345)+(D2*275)+(E2*230)+(F2*185)+ (G2*60)), IF(AND(H2>=39, H2<=50), ((B2*485)+ (C2*365)+(D2*290)+(E2*240)+(F2*195)+(G2*60))),0)

  8. #8
    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,364

    Re: Macro for Nested IF - Too Many Arguments

    Try:

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

  9. #9
    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,364

    Re: Macro for Nested IF - Too Many Arguments

    Note, you have an excess of brackets. When you multiply two values, it takes priority over summing. So, you don't need brackets round a multiplication. And you can also lose the brackets round the sum itself. The formula can be significantly reduced. I've edited the first few lines:

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

  10. #10
    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,364

    Re: Macro for Nested IF - Too Many Arguments

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

  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
    44,364

    Re: Macro for Nested IF - Too Many Arguments

    Out of interest, this is the formula with all excess brackets removed.

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

+ 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. Too many Nested arguments > 7
    By NickTY in forum Office 365
    Replies: 5
    Last Post: 11-15-2018, 10:22 AM
  2. [SOLVED] Help with Nested IF arguments, please
    By KWiseman in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 07-13-2018, 04:23 AM
  3. Too many arguments in nested if function
    By floridashaughn in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-16-2014, 02:23 PM
  4. I am having an issue with an IF formula that contains 4 nested arguments....
    By iamjustinpowell in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-22-2013, 04:00 PM
  5. Need a Nested IF with 12 Arguments
    By daz_uk in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-29-2010, 08:54 AM
  6. Going beyond 7 Nested If Arguments
    By Supdem in forum Excel General
    Replies: 2
    Last Post: 08-05-2009, 03:06 PM

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