+ Reply to Thread
Results 1 to 6 of 6

Problem with multiple if

  1. #1
    Registered User
    Join Date
    08-13-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    6

    Problem with multiple if

    Hi

    I have created the following if function which works well.

    =(IF(C14="SALARIED",$D$2,IF(C14="JH",$D$3,IF(C14="KH",$D$4,IF(C14="CS 3",$D$5,IF(C14="SH AM",$D$6,IF(C14="AJ MON",$D$7,IF(C14="AJ OTHE",$D$8,IF(C14="AJ WED",$D$9,"")))))))))

    I now want to add another condition at the end as follows but I get the error message shown underneath the formula: -

    =(IF(C14="SALARIED",$D$2,IF(C14="JH",$D$3,IF(C14="KH",$D$4,IF(C14="CS 3",$D$5,IF(C14="SH AM",$D$6,IF(C14="AJ MON",$D$7,IF(C14="AJ OTHE",$D$8,IF(C14="AJ WED",$D$9,if(C14="HP 2",$D$10,""))))))))

    "The specified formula cannot be entered because it uses more levels of nesting than are allowed in the current file format"

    Why do I get this message? I'd appreciate anybodies help on this.

    Many thanks

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Problem with multiple if

    There's a limit to how many nested loops you can have, which is why Excel refuses to accept another level.

    Instead you could try something like:

    =OFFSET($D$1,MATCH(C14,{"SALARIED","JH","KH","CS 3","SH AM","AJ MON","AJ OTHE","AJ WED","HP 2"},0),0)

  3. #3
    Forum Expert ben_hensel's Avatar
    Join Date
    01-26-2012
    Location
    Northeast USA
    MS-Off Ver
    Office 365
    Posts
    2,043

    Re: Problem with multiple if

    You can only nest 7 IFS inside each other.

    Well, that's pretty circular compared to what you already know, so I'll explain a little deeper.

    Putting one IF inside another: IF(check, do_something, IF(check, do_something, do_something_else) is called nesting. So, that's got two IFs, one nested inside another. The function you already have, has seven IFs nested like Matroyshka dolls.

    When you try to wrap another one into it, that's the eighth nested IF; that's too many, excel simply can't handle that much.

    Anyway, with the setup you've got, I'd recommend you create a table and pump through that with a LOOKUP, instead of doing IFs.

    Like this:
    =VLOOKUP(c14, that_table, 0)

    "that_table" can either be entered into the function {as an array} or in a section of helper cells.

  4. #4
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Problem with multiple if

    Hi Sharon,

    Your profile says that you have Excel 2010 and when you search IF function in Excel help you get following:-

    "Up to 64 IF functions can be nested as value_if_true and value_if_false arguments to construct more elaborate tests. "

    Are you using Excl 2003?

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  5. #5
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: Problem with multiple if

    This works for me for Excel 2010 but not for Excel 2003:

    =(IF(C14="SALARIED",$D$2,IF(C14="JH",$D$3,IF(C14="KH",$D$4,IF(C14="CS 3",$D$5,IF(C14="SH AM",$D$6,IF(C14="AJ MON",$D$7,IF(C14="AJ OTHE",$D$8,IF(C14="AJ WED",$D$9,IF(C14="HP 2",$D$10,""))))))))))
    Click on star (*) below if this helps

  6. #6
    Registered User
    Join Date
    08-13-2012
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Problem with multiple if

    Many thanks for all your replies - I do have 2010 version however I was saving this as 2003 which was causing the problem. As soon as I re-saved this as 2010, closed and re-opened it it worked! :-)

    Cheers for that.

  7. #7
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Problem with multiple if

    Cheers

    Please mark this thread as [SOLVED].. thanks.

    Regards,
    DILIPandey

    <click on below 'star' if this helps>

+ 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