+ Reply to Thread
Results 1 to 16 of 16

Nested levels of 61 giving error as over 64 levels

  1. #1
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Nested levels of 61 giving error as over 64 levels

    For some reason, my 61 levels of nested IF functions giving me an error when I move one of the statements to the end instead of somewhere in the middle near the end, very weird.
    =IF(ISNUMBER(SEARCH("One",E2)),"One",
    IF(ISNUMBER(SEARCH("Two",E2)),"Two",
    IF(ISNUMBER(SEARCH("Three",E2)),"Three",
    IF(ISNUMBER(SEARCH("Four",E2)),"Four",
    IF(ISNUMBER(SEARCH("Five",E2)),"Five",
    IF(ISNUMBER(SEARCH("SIX",E2)),"Six",
    IF(ISNUMBER(SEARCH("Seven",E2)),"Seven",
    IF(ISNUMBER(SEARCH("Eight",E2)),"Eigt",
    IF(ISNUMBER(SEARCH("Nine",E2)),MID(E2,22,LEN(E2)-22),
    IF(ISNUMBER(SEARCH("Ten",E2)),"Ten",
    IF(ISNUMBER(SEARCH("11",E2)),"11",
    IF(OR(ISNUMBER(SEARCH("12",E2)),ISNUMBER(SEARCH("CHECK #",E2)),AND(LEFT(E2,5)="CHECK",NOT(ISNUMBER(SEARCH("Print",E2))))),"12",
    IF(ISNUMBER(SEARCH("13",E2)),"13",
    IF(ISNUMBER(SEARCH("14",E2)),"14",
    IF(ISNUMBER(SEARCH("15",E2)),"15",
    IF(ISNUMBER(SEARCH("16",E2)),"16",
    IF(ISNUMBER(SEARCH("17",E2)),"17",
    IF(ISNUMBER(SEARCH("18",E2)),"18",
    IF(ISNUMBER(SEARCH("19",E2)),"19",
    IF(ISNUMBER(SEARCH("20",E2)),"20",
    IF(ISNUMBER(SEARCH("21",E2)),"21",
    IF(ISNUMBER(SEARCH("22",E2)),"22",
    IF(ISNUMBER(SEARCH("23",E2)),"23",
    IF(ISNUMBER(SEARCH("24",E2)),"24",
    IF(ISNUMBER(SEARCH("25",E2)),"25",
    IF(AND(ISNUMBER(SEARCH("26",E2)),ISNUMBER(VALUE(MID(E2,SEARCH("26",E2)+4,5)))),MID(E2,SEARCH("26",E2)+10,25),
    IF(ISNUMBER(SEARCH("27",E2)),"27",
    IF(ISNUMBER(SEARCH("28",E2)),"28",
    IF(ISNUMBER(SEARCH("29",E2)),"29",
    IF(ISNUMBER(SEARCH("30",E2)),"30",
    IF(ISNUMBER(SEARCH("31",E2)),"31",
    IF(OR(ISNUMBER(SEARCH("32",E2)),ISNUMBER(SEARCH("32x",E2))),"32",
    IF(ISNUMBER(SEARCH("33",E2)),"33",
    IF(ISNUMBER(SEARCH("34",E2)),"34",
    IF(OR(ISNUMBER(SEARCH("35",E2)),ISNUMBER(SEARCH("35x",E2))),"35",
    IF(ISNUMBER(SEARCH("36",E2)),"36",
    IF(ISNUMBER(SEARCH("37",E2)),"37",
    IF(ISNUMBER(SEARCH("38",E2)),"38",
    IF(OR(ISNUMBER(SEARCH("39",E2)),ISNUMBER(SEARCH("39x",E2)),ISNUMBER(SEARCH("39w",E2))),"39",
    IF(ISNUMBER(SEARCH("40",E2)),"40",
    IF(ISNUMBER(SEARCH("41",E2)),"41",
    IF(ISNUMBER(SEARCH("42",E2)),"42",
    IF(ISNUMBER(SEARCH("43",E2)),"43",
    IF(ISNUMBER(SEARCH("44",E2)),"44",
    IF(ISNUMBER(SEARCH("45",E2)),"45",
    IF(ISNUMBER(SEARCH("46",E2)),"46",
    IF(ISNUMBER(SEARCH("47",E2)),"47",
    IF(ISNUMBER(SEARCH("48",E2)),"48",
    IF(ISNUMBER(SEARCH("49",E2)),"49",
    IF(ISNUMBER(SEARCH("50",E2)),"50",
    IF(ISNUMBER(SEARCH("51",E2)),"51",
    IF(OR(ISNUMBER(SEARCH("52",E2)),ISNUMBER(SEARCH("52x",E2))),"52",
    IF(ISNUMBER(SEARCH("53",E2)),"53",
    IF(AND(ISNUMBER(SEARCH("54",E2)),OR(ISNUMBER(SEARCH("54x",E2)),ISNUMBER(SEARCH("54w",E2)))),"54",
    IF(AND(ISNUMBER(SEARCH("55",E2)),ISNUMBER(SEARCH("55x",E2))),"55",
    IF(ISNUMBER(SEARCH("56",E2)),"56",
    IF(ISNUMBER(SEARCH("57",E2)),"57",
    IF(ISNUMBER(SEARCH("58",E2)),"58",
    IF(OR(ISNUMBER(SEARCH("59",E2)),ISNUMBER(SEARCH("59x",E2))),"59",
    IF(OR(ISNUMBER(SEARCH("60",E2)),ISNUMBER(SEARCH("60x",E2))),"60",
    IF(AND(OR(ISNUMBER(SEARCH("61",E2)),ISNUMBER(SEARCH("61",E2))),ISNUMBER(VALUE(MID(E2,SEARCH("61",E2)+15,5)))),MID(E2,SEARCH("61",E2)+20,LEN(E2)-29),
    "XXX")))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))

    When I created the formula, #61 was #59, but I needed it moved to the end, so the error started popping up.

    Any suggestion would be much appreciated.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Nested levels of 61 giving error as over 64 levels

    You can shorten your formula very seriously with the technique described at https://www.myonlinetraininghub.com/...-list-of-words

  3. #3
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: Nested levels of 61 giving error as over 64 levels

    Also a small sample being attached might shorten it further. See Yellow banner

  4. #4
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Re: Nested levels of 61 giving error as over 64 levels

    Thank you Pepe for the informative link, but my question is more about "why" excel thinks I have 64 levels of nesting and gives me an error, when in reality I have only 61 levels.

    What is more weird, the last IF statement was originally the 58th statement, and it was working very well for months and still does, but I found out certain cells might give me the wrong result, so I moved it to the last position, that is when I started getting the 64 level nesting error message, even though I have only 61 levels. If I leave it as the 58th statement, I have no problems.

    Hope someone can shed some light on this.

    Thank you for your effort.

  5. #5
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Nested levels of 61 giving error as over 64 levels

    There are instructions at the top of the page explaining how to attach your sample workbook.
    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.

  6. #6
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Re: Nested levels of 61 giving error as over 64 levels

    Quote Originally Posted by davsth View Post
    Also a small sample being attached might shorten it further. See Yellow banner
    Thank you davsth for your input. Can you please elaborate about "Yellow banner"?

    As to shortening the list of IF statements, it is not possible, each search term is unique and must be identified uniquely. Once I really reach the 64 levels, I intend to create another column of searches and then combine the two as needed into a third column.

  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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Nested levels of 61 giving error as over 64 levels

    The yellow banner at the top contains instructions telling you how to upload your workbook.

  8. #8
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Re: Nested levels of 61 giving error as over 64 levels

    Hi Ali, thank you for the tip, I do know how to upload sample worksheets, due to confidential nature of column E, I cannot, but like I explained, the problem seems to be excel, not my IF statements.

  9. #9
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Nested levels of 61 giving error as over 64 levels

    Provide a desensitised copy.

    Nobody has the time to imagine the data and recreate it in order to test whether it's Excel or you.

    Having looked at the formula, I can see other nesting going on with AND(OR(...,...), so I don't actually think it's Excel.
    Last edited by AliGW; 05-14-2020 at 01:43 AM.

  10. #10
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,446

    Re: Nested levels of 61 giving error as over 64 levels

    Your formula can perfectly be shortened
    Creating a small list in K1:K5 (with "one" to "five") replaces
    Formula: copy to clipboard
    Please Login or Register  to view this content.

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

    by extending the list the formula does not change except for the range and the number of rows
    So if you have to lookup 100 words just build a list with the one hundred words and enter
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    ( I didn't bother removing the semicolons as it is only an example)
    Replace k1:K100 with whatever suits best
    Last edited by Pepe Le Mokko; 05-14-2020 at 02:43 AM.

  11. #11
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Nested levels of 61 giving error as over 64 levels

    First,
    Although it seems be 61 IF's level, but i believe Excel counts IF's like this:
    IF(AND(statement_1, statement_2)...
    equals: IF(statement_1,IF(statement_2,...)
    then more IF's are counted.
    Second,
    you are using un-needed AND,OR which can be delete, like this:

    IF(OR(ISNUMBER(SEARCH("32",E2)),ISNUMBER(SEARCH("32x",E2)),"32",...
    in which first OR is enough:
    IF(ISNUMBER(SEARCH("32",E2)),"32"...

    and similar with 35,39,52,59,60,61...

    and an AND in "26"
    IF(AND(ISNUMBER(SEARCH("26",E2)),ISNUMBER(VALUE(MID(E2,SEARCH("26",E2)+4,5)))),"26",...
    can be:
    IF(ISNUMBER(VALUE(MID(E2,SEARCH("26",E2)+4,5))),"26",...

    And below is working with 61 IF's:
    =IF(ISNUMBER(SEARCH("One",E2)),"One",
    IF(ISNUMBER(SEARCH("Two",E2)),"Two",
    IF(ISNUMBER(SEARCH("Three",E2)),"Three",
    IF(ISNUMBER(SEARCH("Four",E2)),"Four",
    IF(ISNUMBER(SEARCH("Five",E2)),"Five",
    IF(ISNUMBER(SEARCH("SIX",E2)),"Six",
    IF(ISNUMBER(SEARCH("Seven",E2)),"Seven",
    IF(ISNUMBER(SEARCH("Eight",E2)),"Eigt",
    IF(ISNUMBER(SEARCH("Nine",E2)),MID(E2,22,LEN(E2)-22),
    IF(ISNUMBER(SEARCH("Ten",E2)),"Ten",
    IF(ISNUMBER(SEARCH("11",E2)),"11",
    IF(OR(ISNUMBER(SEARCH("12",E2)),ISNUMBER(SEARCH("CHECK #",E2)),AND(LEFT(E2,5)="CHECK",NOT(ISNUMBER(SEARCH("Print",E2))))),"12",
    IF(ISNUMBER(SEARCH("13",E2)),"13",
    IF(ISNUMBER(SEARCH("14",E2)),"14",
    IF(ISNUMBER(SEARCH("15",E2)),"15",
    IF(ISNUMBER(SEARCH("16",E2)),"16",
    IF(ISNUMBER(SEARCH("17",E2)),"17",
    IF(ISNUMBER(SEARCH("18",E2)),"18",
    IF(ISNUMBER(SEARCH("19",E2)),"19",
    IF(ISNUMBER(SEARCH("20",E2)),"20",
    IF(ISNUMBER(SEARCH("21",E2)),"21",
    IF(ISNUMBER(SEARCH("22",E2)),"22",
    IF(ISNUMBER(SEARCH("23",E2)),"23",
    IF(ISNUMBER(SEARCH("24",E2)),"24",
    IF(ISNUMBER(SEARCH("25",E2)),"25",
    IF(ISNUMBER(VALUE(MID(E2,SEARCH("26",E2)+4,5))),MID(E2,SEARCH("26",E2)+10,25),
    IF(ISNUMBER(SEARCH("27",E2)),"27",
    IF(ISNUMBER(SEARCH("28",E2)),"28",
    IF(ISNUMBER(SEARCH("29",E2)),"29",
    IF(ISNUMBER(SEARCH("30",E2)),"30",
    IF(ISNUMBER(SEARCH("31",E2)),"31",
    IF(ISNUMBER(SEARCH("32",E2)),"32",
    IF(ISNUMBER(SEARCH("33",E2)),"33",
    IF(ISNUMBER(SEARCH("34",E2)),"34",
    IF(ISNUMBER(SEARCH("35",E2)),"35",
    IF(ISNUMBER(SEARCH("36",E2)),"36",
    IF(ISNUMBER(SEARCH("37",E2)),"37",
    IF(ISNUMBER(SEARCH("38",E2)),"38",
    IF(ISNUMBER(SEARCH("39",E2)),"39",
    IF(ISNUMBER(SEARCH("40",E2)),"40",
    IF(ISNUMBER(SEARCH("41",E2)),"41",
    IF(ISNUMBER(SEARCH("42",E2)),"42",
    IF(ISNUMBER(SEARCH("43",E2)),"43",
    IF(ISNUMBER(SEARCH("44",E2)),"44",
    IF(ISNUMBER(SEARCH("45",E2)),"45",
    IF(ISNUMBER(SEARCH("46",E2)),"46",
    IF(ISNUMBER(SEARCH("47",E2)),"47",
    IF(ISNUMBER(SEARCH("48",E2)),"48",
    IF(ISNUMBER(SEARCH("49",E2)),"49",
    IF(ISNUMBER(SEARCH("50",E2)),"50",
    IF(ISNUMBER(SEARCH("51",E2)),"51",
    IF(ISNUMBER(SEARCH("52",E2)),"52",
    IF(ISNUMBER(SEARCH("53",E2)),"53",
    IF(OR(ISNUMBER(SEARCH("54x",E2)),ISNUMBER(SEARCH("54w",E2))),"54",
    IF(ISNUMBER(SEARCH("55x",E2)),"55",
    IF(ISNUMBER(SEARCH("56",E2)),"56",
    IF(ISNUMBER(SEARCH("57",E2)),"57",
    IF(ISNUMBER(SEARCH("58",E2)),"58",
    IF(ISNUMBER(SEARCH("59",E2)),"59",
    IF(ISNUMBER(SEARCH("60",E2)),"60",
    IF(ISNUMBER(VALUE(MID(E2,SEARCH("61",E2)+15,5))),MID(E2,SEARCH("61",E2)+20,LEN(E2)-29),"XXX")))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
    Quang PT

  12. #12
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: Nested levels of 61 giving error as over 64 levels

    A shorter version, I believe it works:
    Please Login or Register  to view this content.

  13. #13
    Valued Forum Contributor
    Join Date
    08-03-2012
    Location
    Newcastle
    MS-Off Ver
    Excel 2007, 2010, 2013, 2016, Office 365
    Posts
    467

    Re: Nested levels of 61 giving error as over 64 levels

    Hi bebo

    As far as I am aware, the whole point of using nested IF formulas is to return the first result where a specified condition is true.
    So your short-formula doesn't do what RJK's long-formula does.
    If cell [E2] contains "qprj1000zz1Four26Two29xxx17" then RJK's formula will give a result of "Four"

    If RJK used a custom function, you could have a lot more than 64 condition levels.
    So you could replace that huge formula with say, =zzz(E2)

    zeddy
    Last edited by zzzeddy; 05-14-2020 at 06:53 AM.

  14. #14
    Registered User
    Join Date
    12-11-2011
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel Pro Plus 2019
    Posts
    67

    Re: Nested levels of 61 giving error as over 64 levels

    Thank you both bebo & eddy, I'm not an excel expert, but I don't think using and/or counts as levels. cause when I keep the order of IF's as is, I have no problem, as soon as I move the 58th statement to the end, that is when I get the error. Something else is happening here and I have no idea.

    And, yes, eddy is right, I need those and/or filters and in specific order IF statements to filter out very specific results that can be similar but not correct.

    Have a great day everyone and stay healthy!

  15. #15
    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,929

    Re: Nested levels of 61 giving error as over 64 levels

    Im not going to try and wade through that monster (kudos on constructing it though), but if excel says you have exceeded the limit of 64, then that's what you have done, even though it may not seem that you have. Perhaps there is a branch in there that is in error or you did not notice, that is taking you down a route that ends up with 64 IF's?

    Either way, it has been my experience that, while beasts like this really do look impressive, there is almost always a far simpler and shorter way to get to the same result, often with much easier to understand and follow syntax's. Below is 1 way that you could find what your cell contains, and then return the number (assuming your example here is representative of your RL situation. It uses a lookup table that contains your "numbers", which then used against your cell to determine what it contains...
    N
    O
    P
    2
    one abconedef one
    3
    two abcfourefg four
    4
    three
    5
    four
    6
    five
    7
    six

    The cells on col O would contain your text cell.
    P2=LOOKUP(9.99999999999999E+307,SEARCH($N$2:$N$7,O2),$N$2:$N$7)
    I copied it down so you can see it working against other text
    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

  16. #16
    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. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,728

    Re: Nested levels of 61 giving error as over 64 levels

    Quote Originally Posted by RJK View Post
    Thank you both bebo & eddy, I'm not an excel expert, but I don't think using and/or counts as levels.
    I pointed this out to you back in post #9 ...

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

+ 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. Nested IF levels have changed...
    By Moo the Dog in forum Tips and Tutorials
    Replies: 4
    Last Post: 01-12-2013, 05:26 PM
  2. Nested IFs and error message "uses more levels of nesting than allowed"
    By pannassi in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-09-2012, 11:48 AM
  3. Nested levels of functions
    By Fixa in forum Excel General
    Replies: 4
    Last Post: 10-19-2011, 03:47 AM
  4. IF function with 14 nested levels
    By Dan Fingerman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 09:05 PM
  5. [SOLVED] IF function with 14 nested levels
    By Dan Fingerman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 PM
  6. IF function with 14 nested levels
    By Dan Fingerman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  7. [SOLVED] IF function with 14 nested levels
    By Gary's Student in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-06-2005, 05:05 AM
  8. IF function with 14 nested levels
    By Dan Fingerman in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04:05 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