+ Reply to Thread
Results 1 to 8 of 8

Dealing with Long Formulas

  1. #1
    Forum Contributor
    Join Date
    07-19-2017
    Location
    usa
    MS-Off Ver
    2016 Professional Plus
    Posts
    128

    Dealing with Long Formulas

    Hi,

    I have combined 30 "if formulas" with & operator. and the length of total resultant formula is more than 9000 characters. It error is "You can't use more than 8192 characters in excel formula". Please help me on this issue.

    Kind Regards,

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: Dealing with Long Formulas

    Without more information (what do the IF() functions look like? What is the overall goal of the formula?), I'm not sure we can help much.

    Are you required to do it all in one cell? My inclination would be to put each IF() function in its own cell, then use something like CONCAT() function or TEXTJOIN() function (available in newer versions of Excel or in alternative spreadsheets like LO Calc or Google Sheets)

    CONCAT() function: https://support.microsoft.com/en-us/...rs=en-us&ad=us
    TEXTJOIN() function: https://support.microsoft.com/en-us/...3-0e8fc845691c

    If, for some reason, you are limited to Excel 2007 as your profile states, then I would still be inclined to use the helper cells, then your final cell can be long concatenate string =cell1&cell2&cell3&...
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,705

    Re: Dealing with Long Formulas

    It might also benefit from a VBA solution but as MrShorty notes there is not enough information here to provide a solution.

    Also, you have 30 IF functions, 9000 characters. That is 300 characters per IF function. This suggests that there may be text in the IF function that could probably just go in a cell instead of baking it into the function.

    Show us the formula or at least part of it.

  4. #4
    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,375

    Re: Dealing with Long Formulas

    As MrShorty says, without more info, it is difficult to offer advice. Do your IF functions refer to other sheets, or even other workbooks? How many Nested IFs are there? Could you combine any of the IF tests using AND or OR? Could you use LOOKUP, VLOOKUP, INDEX/MATCH, CHOOSE, or whatever functions to replace any or all of the IFs? Could you use (short) Dynamic Named Ranges to replace any of the range references?
    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


  5. #5
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Dealing with Long Formulas

    If one's using an additional column of supporting formulas, say actual data in A:G, then IF formulas for individual rows in column H, those could be along the lines of

    H1: =IF(somecondition,something_with_positive_length,"")

    H2: =IF(somecondition,IF(H1<>"",H1&", ","")&something_with_positive_length),H1)

    From H2 down, formulas would only increase in length as the row portion of cell addresses clicked over from 9 to 10, 99 to 100, 999 to 1000, etc.

  6. #6
    Forum Contributor
    Join Date
    07-19-2017
    Location
    usa
    MS-Off Ver
    2016 Professional Plus
    Posts
    128

    Re: Dealing with Long Formulas

    Now here is the formula I am trying to use. I can use concatenate function but that would not be good for me as it would contain alot of space. And my data is already contained in many columns.


    I have attached the formula in text file as the form is not letting me paste the formula reason being stated as HTML content.
    Attached Files Attached Files
    Last edited by anonymous321; 11-24-2020 at 05:17 PM.

  7. #7
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,814

    Re: Dealing with Long Formulas

    And my data is already contained in many columns.
    Excel will allow you to use up to 16000 columns. How close are you to this limit? If needed, can you add another tab to the workbook (Excel's only limit to tabs in a workbook is available memory)?

    What I see in this long unwieldy formula is a repetition of a "lookup" -- look at the value in G6, choose the parameters for the equation, then join together multiple computations from that equation. If you build a proper lookup table, all those IF(G6<...) functions can be replaced (as TMS suggested) with a lookup function [LOOKUP() or VLOOKUP() or HLOOKUP() or INDEX(coefficients,MATCH())], which can dramatically reduce the number of characters needed for this formula.

    Since I don't know what you are allowed/required to do here, I haven't gone to great lengths to figure this out. Is that something you could do -- build a lookup table (or tables) and use a lookup function to extract the needed values from the lookup table?

    If you are unfamiliar with Excel's lookup functions, most people start with VLOOKUP() when learning: https://support.microsoft.com/en-us/...rs=en-us&ad=us

  8. #8
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Dealing with Long Formulas

    Is this REALLY the formula? Every outer/concatenated IF call has the EXACT SAME form, namely IF(ISNUMBER(SEARCH("School",A2)),IF(...)) ? So that if "School" doesn't appear in the value of cell A2, you want the result to be something like FALSEFALSEFALSE...FALSE ? You could save considerable space changing the overall formula to

    The site is acting up, so I can't use the less than symbol, so I've rewritten all comparisons using the greater than symbol since G6 less than x == x greater than G6.

    =IF(COUNTIF(A2,"*School*"),IF(101>G6,...)&IF(101>G6,...)&...&IF(101>G6,...),REPT("FALSE",27))

    You could also reduce IF(101>G6,..a..,IF(OR(G6>100,25001>G6),..b..,IF(OR(G6>25001,60000>G6),..c..))) to

    CHOOSE(MATCH(G6,{-1E300;101;25001;60000}),..a..,..b..,..c..,FALSE).

    Then there's the common pattern of the 2nd arguments to the inner IF calls: 10^(d*LOG(G6)^2+e*LOG(G6)+f) . That could be reduced to 10^SERIESSUM(LOG(G6),0,1,{f;e;d}). More to the point,

    IF(p>G6,10^(dp*LOG(G6)^2+ep*LOG(G6)+fp),IF(OR(G6>p-1,q>G6),10^(dq*LOG(G6)^2+eq*LOG(G6)+fq),IF(OR(G6>q-1,r>G6),10^(dr*LOG(G6)^2+er*LOG(G6)+fr))))

    could be replaced by

    IF(r>G6,10^SERIESSUM(LOG(G6),0,1,INDEX({fp,ep,dp;fq,eq,dq;fr,er,dr},MATCH(G6,{-1E300;101;25001}),0)))

    Actually, since the r>G6 test is common to all the concatenated IF calls, the whole thing could be

    =IF(AND(COUNTIF(A2,"*School*"),60000>G6),(10^SERIESSUM(...))&(10^SERIESSUM(...))&...&(10^SERIESSUM(...)),REPT("FALSE",27))

    You really want either 27 numbers with fractional parts concatenated together with no separators OR 27 instances of FALSE concatenated together?
    Last edited by hrlngrv; 11-24-2020 at 06:21 PM. Reason: typos

+ 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. Dealing with complex IF formulas
    By television in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-05-2018, 01:05 AM
  2. Dealing with headers on very long cells
    By Hematose in forum Excel General
    Replies: 7
    Last Post: 05-16-2014, 06:22 PM
  3. [SOLVED] =IF and =SUMIF formulas creating long long long data processing times.
    By comp in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 03-26-2014, 02:59 PM
  4. Dealing with a long-term measurement data
    By Excelmania013 in forum Excel - New Users/Basics
    Replies: 9
    Last Post: 08-06-2013, 04:54 AM
  5. Dealing with long formulas in Excel 2007
    By thomasutley in forum Excel General
    Replies: 6
    Last Post: 03-02-2012, 09:43 PM
  6. Replies: 1
    Last Post: 07-19-2010, 01:12 PM
  7. dealing with very long numbers
    By 149047 in forum Excel General
    Replies: 3
    Last Post: 07-07-2005, 09: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