+ Reply to Thread
Results 1 to 14 of 14

Nested IF statement error

  1. #1
    Registered User
    Join Date
    10-29-2018
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Nested IF statement error

    Hi All,

    I was just wondering if you guys could help me with something, i am creating a calculator like excel program, concept behind it is that if the unit is say "m2"(which is entered into a cell) then the formula will calculate something a differant way then if the unit was "m3",

    so basically, after entering the first 4 if statements and closing the formula, it worked(unit,m2,m3,m) but when i entered the last unit("100m")(which basically rounds a number to the nearest 100m with the "Ceiling" function, i get a "You have entered too many arguments for this function" error.

    Here is the code i used.

    IF(E15="M2",$E$5*(1+J15),IF(E15="M3",G15*E5*(1+J15),IF(E15="M",$E$6*(1+J15),IF(E15="unit",$E$7*1+J15),if(E15="100m",ceiling(H15,100)))))

    your help & support will be greatly appreciated =)

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,001

    Re: Nested IF statement error

    Welcome to the forum.

    You seem to be missing a final bracket (and a final value_if_false):

    IF(E15="M2",$E$5*(1+J15),IF(E15="M3",G15*E5*(1+J15),IF(E15="M",$E$6*(1+J15),IF(E15="unit",$E$7*1+J15),if(E15="100m",ceiling(H15,100),value_if_false)))))
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.85 (24051214))
    Posts
    8,833

    Re: Nested IF statement error

    in addition to above
    you missed a bracket , so the calc will not be as expected - when E15 = "UNIT"

    IF(E15="M2",$E$5*(1+J15),IF(E15="M3",G15*E5*(1+J15),IF(E15="M",$E$6*(1+J15),IF(E15="unit",$E$7* (
    1+J15),if(E15="100m",ceiling(H15,100)))))


    also a False condition - so if none apply - what should go into the cell
    Wayne
    if my assistance has helped, and only if you wish to , there is an "* Add Reputation" on the left hand side - you can add to my reputation here

    If you have a solution to your thread - Please mark your thread solved do the following: >
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  4. #4
    Registered User
    Join Date
    10-29-2018
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Re: Nested IF statement error

    Hi Ali,

    Thanks for your quick reply, i think i added the "0" and received the same error.

    =IF(E15="M2",$E$5*(1+J15),IF(E15="M3",G15*E5*(1+J15),IF(E15="M",$E$6*(1+J15),IF(E15="unit",$E$7*1+J15),if(E15="100m",ceiling(H15,100),0)))))

  5. #5
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.85 (24051214))
    Posts
    8,833

    Re: Nested IF statement error

    see my post - missing a bracket

    =IF(E15="M2",$E$5*(1+J15),IF(E15="M3",G15*E5*(1+J15),IF(E15="M",$E$6*(1+J15),IF(E15="unit",$E$7*(1+J15),IF(E15="100m",CEILING(H15,100),"no entry")))))

    =IF(E15="M2",$E$5*(1+J15),IF(E15="M3",G15*E5*(1+J15),IF(E15="M",$E$6*(1+J15),IF(E15="unit",$E$7*(1+J15),IF(E15="100m",CEILING(H15,100),0)))))

  6. #6
    Registered User
    Join Date
    10-29-2018
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Re: Nested IF statement error

    Hi Guys,

    Thanks a lot,i really appreciate the help and speedy replies =)

    i will continue feathering my nest =)

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,001

    Re: Nested IF statement error

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  8. #8
    Registered User
    Join Date
    10-29-2018
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Re: Nested IF statement error

    Hi All,

    I was expanding on the previously enquired Nested If statement and i got the same error.


    The code is here:


    =IF(F15="M2",F5*(1+N15),IF(F15="M3",H15*F5*(1+N15),IF(F15="M",J15*(1+N15),IF(F15="unit",J15*(1+N15),IF(F15="100m",CEILING(M15,100),IF(F15="50m",CEILING(M15,100),IF(F15="Surface Area",L15*(1+N15),IF(F15="DAY",I15),IF(F15="ITEM",I15*(1+N15),0)))))))))

    How should i retype this formula to make it work?

    Your guidance would be greatly appreciated =)


    ***Appoligies for not closing the forum when my original question was answered, i knew i might have more questions of the same nature.

  9. #9
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.85 (24051214))
    Posts
    8,833

    Re: Nested IF statement error

    you have a bracket in wrong place
    =IF(F15="M2",F5*(1+N15),IF(F15="M3",H15*F5*(1+N15),IF(F15="M",J15*(1+N15),IF(F15="unit",J15*(1+N15),IF(F15="100m",CEILING(M15,100),IF(F15="50m",CEILING(M15,100),IF(F15="Surface Area",L15*(1+N15),IF(F15="DAY",I15),IF(F15="ITEM",I15*(1+N15),0)))))))))

    try
    =IF(F15="M2",F5*(1+N15),
    IF(F15="M3",H15*F5*(1+N15),
    IF(F15="M",J15*(1+N15),
    IF(F15="unit",J15*(1+N15),
    IF(F15="100m",CEILING(M15,100),
    IF(F15="50m",CEILING(M15,100),
    IF(F15="Surface Area",L15*(1+N15),
    IF(F15="DAY",I15,
    IF(F15="ITEM",I15*(1+N15),0)))))))))

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,001

    Re: Nested IF statement error

    You need to pay attention to your parenthesis as I said before.

    You need this:

    =IF(F15="M2",F5*(1+N15),IF(F15="M3",H15*F5*(1+N15),IF(F15="M",J15*(1+N15),IF(F15="unit",J15*(1+N15),IF(F15="100m",CEILING(M15,100),IF(F15="50m",CEILING(M15,100),IF(F15="Surface Area",L15*(1+N15),IF(F15="DAY",I15,IF(F15="ITEM",I15*(1+N15),0)))))))))

    This is WRONG:

    IF(F15="DAY",I15),IF(F15="I

  11. #11
    Valued Forum Contributor
    Join Date
    01-07-2022
    Location
    Europe
    MS-Off Ver
    Office 365
    Posts
    473

    Re: Nested IF statement error

    I think the issue is in the IF(F15="DAY",I15) part - if I've understood the formula correctly there shouldn't be a bracket after I15.

    Your formula would then be
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    For complex nested IFs, it can be useful to use a tool like https://www.excelformulabeautifier.com/ to respace the formula in a more readable format. E.g. using the formula above comes out as below, which is easier to follow

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <<< If you have valued anyone's contributions in this thread, please click * to thank them for their efforts

  12. #12
    Registered User
    Join Date
    10-29-2018
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Re: Nested IF statement error

    Thanks a million =)
    i will try and code it like that from now on

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2407 (Windows 11 23H2 64-bit)
    Posts
    83,001

    Re: Nested IF statement error

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  14. #14
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.85 (24051214))
    Posts
    8,833

    Re: Nested IF statement error

    try setting out as i have done in something like a note pad or some simple text editor
    make it much easier to see errors like that
    and work out any brackets that are needed or missing

    much much easier to see then in excel formula bar - although often excel will give a hint as to where the issue maybe

+ 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. I keep getting an error with my nested IF AND statement
    By higgi24 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-22-2017, 11:54 AM
  2. [SOLVED] Multiple Nested IF Statement error
    By Seth_ in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-03-2016, 12:54 PM
  3. Nested IF statement error. Nested True statement is not triggering
    By Lucas7040 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-26-2016, 11:41 AM
  4. [SOLVED] Nested AND statement Error
    By mdovey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-25-2013, 08:41 PM
  5. [SOLVED] IS ERROR with nested if statement
    By renden in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-06-2012, 05:46 AM
  6. Error on Nested If Statement
    By ValentineNicole in forum Excel General
    Replies: 5
    Last Post: 02-18-2011, 03:29 PM
  7. Replies: 3
    Last Post: 08-10-2006, 11:30 AM

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