+ Reply to Thread
Results 1 to 52 of 52

Nested IF function causing formula overflow

  1. #1
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Nested IF function causing formula overflow

    Hi, there

    First of all, I'm very inexperienced with Excel, have only been dabbling with it for a couple days, so I know only the basic's basics (and probably not even all of them).

    The situation is that I want, let's say, cell C1 to do B1-A1, which is simple enough. The problem is that I don't want plain B1's or A1's values, I want them to be applied to a formula, which would also be simple enough, except the formula they must be applied to depends on what initial value A1 and B1 have. So the only thing I could find that could do something like this was nested IF functions.

    Here's a more concrete example, in case my explanation made no sense: C1 = IF(1<=B1<500;[Formula#1];IF(500<=B1<1000;[Formula#2]... and so on and so forth.

    There are 20 different formulas, meaning 20 nested if statements (which I may eventually need to expand to 40), which very quickly hits the token limit, especially since each individual formula is quite lengthy and complex. Even if I try splitting it to, for example, calculate A1 applied to a formula in cell D1 and B1 applied to a formula be calculated in E1, they both still overflow.

    My searches on Google haven't turned out too well, since, considering I'm pretty new with this, I don't quite know what to search for, what I find doesn't seem to be related to it and even if it is, I can't identify it, due to not knowing my way around Excel that well, yet. So if anybody knows how to solve this issue and if possibly explain it more or less thoroughly, I'd greatly appreciate it.


    Edit: here's a sample of what I'm trying to do Sample.xls
    Last edited by Vicius; 01-08-2013 at 03:33 PM.

  2. #2
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Nested IF function causing formula overflow

    you can provide a sample workbook for the members to play around.

    To attach a sample workbook.

    When you are in Advanced reply, click on the paperclip to open the upload window.

    View Pic


    and possible put some note's on what you expected.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  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: Nested IF function causing formula overflow

    C1 = IF(AND(1<=B1,B1<500);[Formula#1];IF(AND(500<=B1,B1<1000);[Formula#2]...

    But, if you have that many it will still fail after 7 IFs.

    Have a look at:

    http://www.cpearson.com/excel/nested.htm


    Regards, TMS
    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


  4. #4
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Quote Originally Posted by TMShucks View Post
    C1 = IF(AND(1<=B1,B1<500);[Formula#1];IF(AND(500<=B1,B1<1000);[Formula#2]...

    But, if you have that many it will still fail after 7 IFs.

    Have a look at:

    http://www.cpearson.com/excel/nested.htm


    Regards, TMS
    Thanks, that link's solution looks exactly like what I need.

    Edit: nvm, just noticed there's a link in there explaining named formulas.
    Last edited by Vicius; 01-07-2013 at 09:01 PM.

  5. #5
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Nested IF function causing formula overflow

    Just a hint as well, you should change your profile location to where you actually are...there are regional differences on separators (yours are obviously different than mine, I use ",", you are using ";"),so that at the very least, we can suggest changing the separators if there are problems with offered solutions
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  6. #6
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Thanks, but it's fine, the actual writing of functions I can handle, the problem is knowing which functions to use and what they do.

  7. #7
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Ok, I think I got it with the naming formulas thing, but I just have one last question: how do I define the named formula in a place, then set the variable to be used on another cell?

    I tried uploading a sample here, but I couldn't figure out, so here goes a raw written description each cell's contents:



    Please Login or Register  to view this content.
    Is there a way to make the named formula have their variable unknown, and then set the variable on the named formulas on the cell that will use the named formula? If so, how? I know that you can assign the variable on the named formula itself, but then I'll need to copy the named formula columns before each new set of data, which I'd rather avoid.

    Secondly: each individual formula that composes the named formulas has several sets of parenthesis in them, will that not possibly make the formula overflow anyway?
    Last edited by Vicius; 01-07-2013 at 10:09 PM.

  8. #8
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Nested IF function causing formula overflow

    To attach a sample workbook.

    When you are in Advanced reply, click on the paperclip to open the upload window.

    View Pic

  9. #9
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Yes, I know all that. I tried it before and it didn't work. Selected the file to upload, nothing happened, I tried everything I could. It was a supported file extension.

    Anyway, it's a rather simple question, I guess. Is a sample workbook really necessary? How to set the variable on a named formula to be a different cell than the one set when the formula was named? Like I set the formula on A1 as =5B1-2B1^2+5, for example, then name it F_1. How do I make it so another cell, say F8, uses this same F_1 formula, but with C3 as the variable, instead of B1?
    Last edited by Vicius; 01-08-2013 at 12:03 PM.

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

    Re: Nested IF function causing formula overflow

    I know nothing about named formula (sorry), but I do know you can avoid nested IF problems by using a CHOOSE function:

    =CHOOSE(MATCH(A2,{0,500,1000,5000,10000},1),[Formula1],[Formula2],[Formula3],[Formula4],[Formula5])

    So if A2 is <500 Formula 1 will be used, if it's 500-999 then Formula 2, and so on.

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

    Re: Nested IF function causing formula overflow

    Not too simple. the distance from A1 to F8 very different with distance from B1 to C3, we may have to use ADDRESS function to convert.
    Quang PT

  12. #12
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    That looks very promising, Andrew, thank you, I'll give it a try.

    Edit: tried it, and unless I fluffed up, somehow, which is actually very likely, it still gives me a formula overflow error, before I even put the formulas in, and only make it match to five different values.

    Guess I'll eat my own words to dredwolf about the location thing, it does seem to be getting in the way for this. My version is in BR Portuguese, so identifying the corresponding function names is not being as easy as I first imagined.
    Last edited by Vicius; 01-08-2013 at 01:01 PM.

  13. #13
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    Quote Originally Posted by Vicius View Post
    Like I set the formula on A1 as =5B1-2B1^2+5, for example, then name it F_1. How do I make it so another cell, say F8, uses this same F_1 formula, but with C3 as the variable, instead of B1?
    If you defined the name F_1 as

    =5*B1 - 2*B1^2 + 5

    while the cursor was in A1, then you just need to enter:

    =F_1

    into cell B3 and it will pick up the values from C3, i.e. 1 cell across on the same row, relative to the cell which contains the named formula.

    Hope this helps.

    Pete

  14. #14
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Thanks, but unfortunately if that's the only way, then named formulas are no good to me, as in my actual spreadsheet I'd need to use F_1 with two different variable values on the same cell calculation. I could split the calculation into three different cells, one for each formula calculation, then the actual subtraction of one by the other, but it'd be way too messy and too much of a hassle, there has to be a better way.

    The CHOOSE & MATCH functions suggestion looks very promising for that, but like I said I'm having a bit of trouble actually setting it up right. The CHOOSE function I think I found, but the MATCH one in portuguese i'm having a bit of trouble with, as there are many functions with names that could fit that. Also I don't quite understand exactly what they do individually, yet. The description on both the Help section and function assistant for CHOOSE is kind of ambiguous and confusing and since I haven't even properly identified MATCH yet, I don't even know which description/help section to read.

  15. #15
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    The Portuguese for CHOOSE is SELECCIONAR, but it might be ESCOLHER if you are in Brazil.

    MATCH is CORRESP in both.

    As mentioned above, if you could attach a sample workbook we might be able to help you more.

    Hope this helps.

    Pete

  16. #16
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Thank you, those were the ones I tried to use after Andrew's post, and gave me the formula overflow error as soon as I had it at "=CHOOSE(MATCH(A2,{0,500}" (or "=ESCOLHER(CORRESP(A2{0,500}" in my language) regardless of if I tried closing brackets and finishing the function properly, which is rather odd and is why I wasn't sure if I picked the right function for MATCH, as I'm fairly sure I filled it out properly.

    At any rate, I chose a less elegant way to solve my problem. I created 21 columns, and put "IF(AND(1<=A1;500>A1);Formula#1;0" on B1, "IF(AND(500<=A1;1000>A1);Formula#2;0" on C1 and so on till Formula#20, then on V1 I set it to =SUM(B1:U1). I then chose to hide columns B through U to keep things tidy and easy to read. Solves my problem nicely, except for one last thing. I need to copy the columns over and over for every new data input and the ones I chose to hide are not hidden upon being pasted. Is there a way to make the copied hidden columns remain hidden after pasting?


    Edit: finally managed to get a working upload of the initial problem. Here it is Sample.xls
    Last edited by Vicius; 01-08-2013 at 03:31 PM.

  17. #17
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    I'd be interested in knowing what your 20 formulae are, as I think I have a way of achieving this more simply using VLOOKUP to return the formula which is then evaluated using a user-defined function. Can you copy the formula that you would normally have in D1 (and G1, J1 etc) to a post here? Just click in the formula bar, highlight the complete formula and do CTRL-C and then paste it with CTRL-V to a post.

    Pete

  18. #18
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    The formulae are extremely long and I'd have to replace a whole bunch of it's format so it can be read by your english excel (for example, BRPT version uses commas to separate decimals, whereas EN version uses periods, SEN for sinus instead of SIN and so on), which in turn I'd have to revert back to my own formatting after you use them in your table. Wouldn't it be possible for you to make such a sample using placeholders for the formulae as I did in my own? The formulae work individually just fine so there's no real need to test that.

  19. #19
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    I have a file where I can look up English and Portuguese names for functions, and I'm aware of the use of semicolons instead of commas, and commas instead of full-stops etc., so I think I'll be able to manage.

    I also need to know what variations in B1 trigger the different formulae, as you've only given a few examples, 1-500, 500-1000, 1000-1500 etc. - is it always a range of 500? I would also need to know which variables you will use for those formulae - will it always be B1, as in post #14 you seem to imply that sometimes there will be two variables. If you are using trigonometric functions, will you be taking the variables directly, or treating them as degrees? If you post the formula from D1 then I can see the answers to these and any other questions that I might have.

    Many people have been trying to help you in this thread, but you seem reluctant to give us the information we need to be able to help you - I leave it with you.

    Pete

  20. #20
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    The range starts at 1-500 then proceeds at 500 steps up until 10000.

    The formulae only have one variable, they're simply curve functions. What I posted in #14 was referring to the fact that I have cells that do, for example, A1 applied as variable to one of the 20 formulae depending on it's range subtracted by B1 applied to one of the same 20 formulae depending on it's range.

    The formula of how I want to calculate D1 is in the sample I posted, except with placeholders for the individual formulas, all you have to do is put a "=" in front of it, as commented beneath it. Unless there was some sort of issue when saving or incompatibilities between our versions or something which is preventing you from seeing what I wrote in D1, which more or less happened earlier when I tried to upload a sample workbook and couldn't.

    And yes, to be honest, I am a bit reluctant to release the specific formulas not because I think anybody here can misuse it, but because I'd rather not have them out in a place where google and other search engines may find them, although the reason I gave on my previous post was also a big factor in it. Frankly, I don't understand why the specific formulas are required to solve my problem, but if you absolutely must have them in order to do so, I can send them to you via private message. The reason I hadn't posted a sample workbook from the start, however, was that for some reason the upload tool wasn't accepting it or changing the data in the cells to useless gibberish.

    Don't get me wrong, by the way, I truly appreciate the help you guys are offering.
    Last edited by Vicius; 01-08-2013 at 11:34 PM.

  21. #21
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    Well, this is a public forum where there are lots of people willing to help for FREE - the "price" you pay is to expose your work and solutions to all who visit here, so that all may benefit. If you want a "private" solution then I suggest you contact a local Excel consultant and pay for it.

    My offer to help you is still there, as long as you post an example of the formula that you are using at present, as in Post #17.

    Pete

  22. #22
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Okay, I figured out how to do the VLOOKUP function, more or less, which should save me a lot of trouble. The problem is that it is returning the raw number from the index cells, rather than applying the value from the search criteria cell to the formula in the index cell.

    Here is a sample that illustrates it better: vlookup sample.xls

    Keep in mind that everything is in the Brazillian Portuguese version of formatting both in this and my previous sample, so if your excel can't read it or gives you errors, it's because of language incompatibilities.

    Edit: oops, put the link to the wrong sample there, fixed it now.
    Attached Files Attached Files
    Last edited by Vicius; 01-09-2013 at 06:31 PM.

  23. #23
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    That was not what I meant when I suggested using VLOOKUP, but to draw this to a conclusion I've picked up on Andrew's suggestion in post #10 and put this formula in cell D1 of your original sample:

    =CHOOSE(INT(B1/500)+1,B1+100,B1-100,B1/100)

    If you download the attached file then this should be translated for you, as Excel uses tokens to store function names and separators.

    The first parameter of the CHOOSE function, i.e. INT(B1/500)+1, will return 1 for values of B1 in the range 0-500, then 2 for the range 501-1000, then 3 for the range 1001-1500, and so on. So for the first range the CHOOSE function will evaluate the expression B1+100. If B1 is between 501 and 1000, then the CHOOSE function will evaluate the expression B1-100, and so on for other ranges.

    These are fairly trivial examples, and there are only 3 of them, but if you put your various formulae into the CHOOSE function (without the = sign), and extend it to a list of 20 of them, then you should have a formula which does what you are requiring. You can have a similar CHOOSE function following it, using A1 as the variable. The formula can be copied into cell G1, as in the example file, and the references to B1 will change to E1.

    I hope this satisfies your requirements - if so, please mark the thread as Solved by clicking on "Thread Tools" immediately above your first post. You might also like to show your appreciation to those who have tried to help you by clicking on the "star" icon in the bottom left corner of any post that you have found to be helpful (not just in this thread).

    Hope this helps.

    Pete
    Attached Files Attached Files

  24. #24
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Nested IF function causing formula overflow

    @Vicius

    Would you also change your location to something more meaningful as requested by dredwolf in post #5.

    This can help in all sorts of ways since knowing your location helps not only with knowing things like your parameter separator character as dredwolf says, but also your system locales for date standards and indeed your time zone.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  25. #25
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Quote Originally Posted by Pete_UK View Post
    That was not what I meant when I suggested using VLOOKUP, but to draw this to a conclusion I've picked up on Andrew's suggestion in post #10 and put this formula in cell D1 of your original sample:

    =CHOOSE(INT(B1/500)+1,B1+100,B1-100,B1/100)

    If you download the attached file then this should be translated for you, as Excel uses tokens to store function names and separators.

    The first parameter of the CHOOSE function, i.e. INT(B1/500)+1, will return 1 for values of B1 in the range 0-500, then 2 for the range 501-1000, then 3 for the range 1001-1500, and so on. So for the first range the CHOOSE function will evaluate the expression B1+100. If B1 is between 501 and 1000, then the CHOOSE function will evaluate the expression B1-100, and so on for other ranges.

    These are fairly trivial examples, and there are only 3 of them, but if you put your various formulae into the CHOOSE function (without the = sign), and extend it to a list of 20 of them, then you should have a formula which does what you are requiring. You can have a similar CHOOSE function following it, using A1 as the variable. The formula can be copied into cell G1, as in the example file, and the references to B1 will change to E1.

    I hope this satisfies your requirements - if so, please mark the thread as Solved by clicking on "Thread Tools" immediately above your first post. You might also like to show your appreciation to those who have tried to help you by clicking on the "star" icon in the bottom left corner of any post that you have found to be helpful (not just in this thread).

    Hope this helps.

    Pete
    Thank you, your explanation helped me understand better how the CHOOSE function works, and the INT bit was very clever.

    Apparently this seems to solve my issue, for now at least. It may no longer work once I need to expand to using 40 formulae instead of 20, but it'll probably be some time until then.

    I have learned much from all the replies. I'll mark it as solved and spread some rep around.
    Last edited by Vicius; 01-09-2013 at 09:01 PM.

  26. #26
    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: Nested IF function causing formula overflow

    Thanks for the rep. Feels a bit undeserved in relation to the effort Pete put in but, nevertheless, gratefully received.

    Regards, TMS

  27. #27
    Forum Expert Moo the Dog's Avatar
    Join Date
    09-28-2012
    Location
    Wisconsin
    MS-Off Ver
    Office 365 (PC & Mac)
    Posts
    1,845

    Re: Nested IF function causing formula overflow

    The nested IF limit was raised to 64 levels in Excel 2007... just FYI for anyone stumbling upon this thread.

    - Moo

  28. #28
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    @TMSchucks: I gave it to every post that offered me some kind of knowledge I did not have before, either directly or by providing me with ideas that I looked into. In either case, I learned more about using Excel, so that's as good a reason as any to give rep.

  29. #29
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Hmm, apparently it is not quite as solved as I thought.

    For some reason, the CHOOSE function is only allowing me to input 15 out of the 30 values (20 of which I would need). If I try to input a 16th or more, it instantly becomes an Error #512, meaning formula overflow again...

    Edit: nvm, solved it by using 3 cells, each with 7 nested IF functions for the formula, then hid the lines. Seems like the only way to escape this damn formula overflow is getting a new Excel...
    Last edited by Vicius; 01-09-2013 at 10:30 PM.

  30. #30
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    I don't have XL2003 anymore, but XL2007 allows up to 254 choices in CHOOSE. If the limit is 12 in XL2003, then you can overcome it by having something like this:

    =IF(INT(B1/500)+1<=12,CHOOSE(INT(B1/500)+1,B1+100,B1-100,B1/100,formula_4,formula_5,formula_6,formula_7,formula_8,formula_9,formula_10,formula_11,formula_12),
    CHOOSE(INT(B1/500)+1,formula_13,formula_14,formula_15,formula_16,formula_17,formula_18,formula_19,formula_20,formula_21,formula_22,formula_23,formula_24))

    Hope this helps.

    Pete

  31. #31
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Quote Originally Posted by Pete_UK View Post
    I don't have XL2003 anymore, but XL2007 allows up to 254 choices in CHOOSE. If the limit is 12 in XL2003, then you can overcome it by having something like this:

    =IF(INT(B1/500)+1<=12,CHOOSE(INT(B1/500)+1,B1+100,B1-100,B1/100,formula_4,formula_5,formula_6,formula_7,formula_8,formula_9,formula_10,formula_11,formula_12),
    CHOOSE(INT(B1/500)+1,formula_13,formula_14,formula_15,formula_16,formula_17,formula_18,formula_19,formula_20,formula_21,formula_22,formula_23,formula_24))

    Hope this helps.

    Pete
    The limit is supposed to be 30 in mine. But it's overflowing way earlier than that, probably due to the complexity of the formulas. I'll give your suggestion a try, looks interesting too, thanks.

    Edit: still causes formula overflow.
    Last edited by Vicius; 01-09-2013 at 10:45 PM.

  32. #32
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Nested IF function causing formula overflow

    From your last sample file in post #22, isn't it possible to change all cell reference in those formulas to A23 then your vlookup??
    sample formulas from that file

    6.22303E-20*A23^7 - 2.537E-28*A23^10 initially it refred to A1

    =VLOOKUP(A23,A1:B21,2)

  33. #33
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Yes, but that would require me to make a new table for every new data input, since the variables on the formulas are fixed, which would be kind of an unnecessary hassle.
    Last edited by Vicius; 01-09-2013 at 10:44 PM.

  34. #34
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Nested IF function causing formula overflow

    make a new table for every new data input
    from your file attached ,no.....the vlookup will return the range where the formula is located and use that formula for computation


    edit attaching sample file..

    vladvlook.xlsx
    Last edited by vlady; 01-09-2013 at 11:11 PM.

  35. #35
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    You mean making a cell entry on the table for each unit between 1 and 10000, if I understood correctly?
    Unfortunately that's not a possibility, since the input data includes decimals, which have a significantly different result when applied to the formulas. Basically, for 2 decimals, which is the least I need for the spreadsheet, it'd require nearly one million entries from 1 to 10000, then another million once I expand the spreadsheet to also include another 20 formulas for the 10000 to 20000 range.

    I give up, I'm getting Excel 2010 just for the higher token limit.
    Last edited by Vicius; 01-09-2013 at 11:53 PM.

  36. #36
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,361

    Re: Nested IF function causing formula overflow

    You mean making a cell entry on the table for each unit between 1 and 10000, if I understood correctly?
    No you will not create a table for each unit. I just created that just for comparison purposes as the note on the sheet above that tells.
    ....

    just try may sample workbook with different numbers you wish then compute that number manually, if necessary compare the resulting figures.

    for example the number 501.23 - so it should use the formula 500 to 1000 right? the original formula is 40.029-0.000000000000000485*A2^6-0.000300705537*A2^4-0.0014195*A2^2
    so change A3 with the number 501.23

    ---what is your expected output for this number (501.23 computed manually)

    Put the number 501.23 on the sample workbook I provided with the vlookup....
    compare results..

  37. #37
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Ok, upgraded to Excel 2010 english.

    Tried the formulas that were giving me overflow error before, and while they don't seem to be doing it anymore, excel isn't really calculating them either. I tried both the CHOOSE and the nested IFs. On both accounts it simply checks which condition is met, then writes the correspondent individual formula on the cell, without calculating it, rather than give it's result. I tried right-clicking the cells to check their category and they all seem to be under General, so I don't understand why it's not calculating anything.

    I switched the commas from decimals back to periods, the SEN to SIN, tried putting an "=" sign in front of the individual formulas inside the quotes, pressing F9 (read somewhere it forces Excel to calculate), but still nothing.

  38. #38
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Nested IF function causing formula overflow

    @Vicius

    Are you going to change your location as requested in post #s 5 & 24?

  39. #39
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    If you don't tell us what formulae you are using then we can't advise you where you might have gone wrong with the syntax etc. - you did say in your opening post that you are an inexperienced user, so you may be trying to use formulae incorrectly within the CHOOSE function.

    I've put together another example which is based on my suggestions in post #17 (seems so long ago now). In this I have set up a table in cells D9:E29 which has the start points of the ranges in column D and in column E there are a few generic expressions representing formulae, i.e.:

    x + 100
    x - 100
    x / 50
    x^2 + 3*x +16

    Notice that there are no = signs, and no cell references - instead, the variable is x, and these are VALID expressions in Excel if the x is replaced with a cell reference.

    In cell D1 I have this formula:

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


    where E_val is a user-defined function (UDF), defined as:

    Please Login or Register  to view this content.
    The VLOOKUP function returns the appropriate string depending on the value of B1, and the UDF substitutes the cell reference for "x" and then evaluates the resulting expression. The formula can be copied into G1 etc. to pick up the values in E1, as before.

    So, you need to put valid expressions in that format down column E, and you should have what you want. You must enable macros when you first open the file.

    I hope this puts it to bed now.

    Pete
    Attached Files Attached Files

  40. #40
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Quote Originally Posted by Pete_UK View Post
    If you don't tell us what formulae you are using then we can't advise you where you might have gone wrong with the syntax etc. - you did say in your opening post that you are an inexperienced user, so you may be trying to use formulae incorrectly within the CHOOSE function.
    When I place the individual formulas on a cell, excel calculates them, so apparently they are "legible" by Excel, no syntax errors on the formulae themselves. It is when I input them as the CHOOSE function values, or the IF function's "if true" sections that Excel doesn't calculate them, despite me using the function wizard to set them up, so unless the function wizard messes things up itself, which I doubt, then the way I'm writing the functions is not the problem. here's an example of how the CHOOSE function looks and doesn't get calculated, rather it simply places the raw formula that meets the requirements on the cell:

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


    Quote Originally Posted by Pete_UK View Post
    I've put together another example which is based on my suggestions in post #17 (seems so long ago now). In this I have set up a table in cells D9:E29 which has the start points of the ranges in column D and in column E there are a few generic expressions representing formulae, i.e.:

    x + 100
    x - 100
    x / 50
    x^2 + 3*x +16

    Notice that there are no = signs, and no cell references - instead, the variable is x, and these are VALID expressions in Excel if the x is replaced with a cell reference.

    In cell D1 I have this formula:

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


    where E_val is a user-defined function (UDF), defined as:

    Please Login or Register  to view this content.
    The VLOOKUP function returns the appropriate string depending on the value of B1, and the UDF substitutes the cell reference for "x" and then evaluates the resulting expression. The formula can be copied into G1 etc. to pick up the values in E1, as before.

    So, you need to put valid expressions in that format down column E, and you should have what you want. You must enable macros when you first open the file.

    I hope this puts it to bed now.

    Pete
    Thanks, this seems like an interesting alternative, I'll give it a try.

  41. #41
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Nested IF function causing formula overflow

    @Vicius

    I would really appreciate it since you've already been asked if you'd take the time to change your location.

  42. #42
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    My location is irrelevant, I just said my new Excel is in english. If anything putting my location there would be more confusing than not for the people trying to help, now.

  43. #43
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Nested IF function causing formula overflow

    I don't agree for the reasons that you have been given. Knowing your location can only help and it is NOT irrelevant. It can never be a disadvantage.

    Please change it.

    Why would you not want to do so when you have been asked? Those who answer your questions give freely of their time and knowing people's locations can often save time by avoiding wasted effort and uncertainty.

    Now you have been asked I expect to see it changed.

  44. #44
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    @ Richard

    Fine, if it's so important there it is. Told you it doesn't really help at all, though.

    @ Pete

    I tried that User Defined Function. It gives me a #VALUE! error. All the formulae are valid individually and I set them up similarly to how you explained. I don't understand what's going wrong. The evaluate tool says =E_val([formula];B6) returns in error, but doesn't really tell me what's wrong.

    Also, in your sample the D1 cell returns 100, yet B1 is valued at 55, so it should result in 155 (x+100, B1 substituting x, should become 55+100). Maybe there's something wrong in the VBA script? I have zero knowledge about it, so I wouldn't know.

  45. #45
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Nested IF function causing formula overflow

    It DOES help.
    you get responses from from people in you region, or using same excel as you, or can translate the formulas...etc...
    However, I still dont get what problem you have with vlady's VLOOKUP solution in post #34,I have 65 formulas working with that particular solution..similar results with just about all the solutions offered...so my question is, have you ACTUALLY tried the solutions offered with what you have posted? (ie.. put different values in the cells TOLD to you to put them in, LOOKED at the results..etc..)
    Here is a simpler version of Vlady's post...trying to explain what is happening with the vlookup..:Vicius.sol1.xls
    Actually E1 or F1 result will be based on the value you enter into D1, works out to the same for your purposes, change the formulas in B or C Columns, and the Result will be based on what you enter in D1...the way I have it set-up is to show YOU which formula is used for the value YOU enter into D1

    Edit-
    Sorry for typos, got a flaky keyboard...
    Last edited by dredwolf; 01-11-2013 at 01:30 AM.

  46. #46
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Nested IF function causing formula overflow

    darnit..meant this:Vicius.sol2.xls.xlsx

  47. #47
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Nested IF function causing formula overflow

    Quote Originally Posted by Vicius View Post
    @ Richard

    Fine, if it's so important there it is. Told you it doesn't really help at all, though.
    Thank you. We'll have to differ on this subject. But since I've over 8000 posts on this forum I think I'm entitled to have the view that I - and others do. Believe me I've wasted time in the past when knowing this simple fact might have prevented this.

  48. #48
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    Quote Originally Posted by dredwolf View Post
    It DOES help.
    you get responses from from people in you region, or using same excel as you, or can translate the formulas...etc...
    However, I still dont get what problem you have with vlady's VLOOKUP solution in post #34,I have 65 formulas working with that particular solution..similar results with just about all the solutions offered...so my question is, have you ACTUALLY tried the solutions offered with what you have posted? (ie.. put different values in the cells TOLD to you to put them in, LOOKED at the results..etc..)
    Here is a simpler version of Vlady's post...trying to explain what is happening with the vlookup..:Attachment 205722
    Actually E1 or F1 result will be based on the value you enter into D1, works out to the same for your purposes, change the formulas in B or C Columns, and the Result will be based on what you enter in D1...the way I have it set-up is to show YOU which formula is used for the value YOU enter into D1

    Edit-
    Sorry for typos, got a flaky keyboard...
    The problem with vlady's suggestion is that I have to make a new table for every new data input. For example, in your sample, F2 returns the proper formula and value depending on D2, but the actual spreadsheet I'll use keeps expanding to the right, as I make more and new data inputs. If I put a new number in G2, and set H2 to do the same VLOOKUP, the number returned will be based on D2 still. To have it return based on the new data input I'd have to copy the entire table over for the new data input.

  49. #49
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Nested IF function causing formula overflow

    Re your post #44 - did you enable macros when you opened the file? You should get a little warning message above the sheet area, and if you click on the options button you can choose to Enable macros - if you don't then you will get the #VALUE error in D1 and G1.

    In the file that I submitted I get these values for different values in B1:

    B1 ...... D1
    55 ...... 155
    499 .... 599
    500 .... 400
    1000 .. 20
    1500 .. 2254516

    which is what I would expect from the example expressions that I had in there.

    Hope this helps.

    Pete

  50. #50
    Registered User
    Join Date
    01-07-2013
    Location
    Dubai
    MS-Off Ver
    Excel 2010 English
    Posts
    23

    Re: Nested IF function causing formula overflow

    I enabled macros for both your sample and my main sheet, but for some reason the E_val function isn't actually substituting x by the parameter cell's value, it just returns as 0 in your sample (when macros were disabled it simply showed the cell's formula, so I suppose I didn't mess that up). I assume this could be what's causing my #VALUE! error, as well. Does VBA scripting change from Excel 2007 to 2010?

  51. #51
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Nested IF function causing formula overflow

    Just by chance, you don't have show formulas checked, rather than show values?
    I only ask this because I have NO problems getting the expected results and you are having such a difficult time with it..

  52. #52
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Nested IF function causing formula overflow

    I'm going to offer one more solution, PLEASE look at it closely before you dismiss it(AND it is just a variation of whats already been offered, I believe by Pete_UK), it just uses excel functions to do the brute work:
    NOTE+++ this particular solution ONLY works on the value directly to the left of it +++
    Check the attached:Vicius.sol2.xlsm

+ 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