+ Reply to Thread
Results 1 to 9 of 9

Excel hangs due to many formulas, is it possible to create a more efficient process?

  1. #1
    Registered User
    Join Date
    06-20-2017
    Location
    Europe
    MS-Off Ver
    MS Office 2016
    Posts
    20

    Excel hangs due to many formulas, is it possible to create a more efficient process?

    Hi everyone!

    Here I have what I think is an interesting issue.
    I've created this file (attached in the post) to combine words but I guess that as a result of the many formulas and that my PC is not that great, Excel hangs and stops working while using the file. I was wondering if there is a way to make the process lighter, perhaps?

    Here is the explanation of how the file works:
    - Cells C1:F2 and A22:A1021 are used for some formulas.
    - Each language has its sheet.
    - Rows 4 to 18 are used to select the language of the words. The chosen language must be written in cell B4.
    - Columns B and E display words from the sheet of the picked language (at cell B4). [Note: for this sample, there are only words for EN (English) and ES (Spanish)]. Column B shows terms composed of 1 word; column E shows terms composed of more than 1 word.
    - Column H picks some words of column B (terms that doesn't have an X) but also words can be added manually.
    - Column K displays combination of words in column H. The combination is made through sheet KWs Comb.
    - Columns N, Q and T displays combination for certain words that are allways the same.
    - Finally, column Y concatenates all the suitable terms (that don't have an X in its Y/N column).

    Again, the main question is: is there any way to make the process faster and to avoid Excel to freeze?
    If I divide the main sheet ("TEST") into various sheets, could it be faster? A macro could help?

    If anyone has any suggestions, I will be delighted to read them. Thanks in advance!
    Attached Files Attached Files

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

    Re: Excel hangs due to many formulas, is it possible to create a more efficient process?

    Short but useless answer -- yes, I think this file can be made to work faster. I see a lot of common "bottlenecks" in your file. I don't know what help you will need to re-write this spreadsheet, so I will just point out the problems I see. If you need help changing any of these, let us know, and we will help you make changes.

    1) There are a lot of linear VLOOKUP() functions -- =VLOOKUP(value,table,column,FALSE). Linear lookups are very slow. With this many lookups, I would do anything I could to make these binary lookups (4th argument=TRUE), which means sorting the lookup tables and editing the formulas.
    2) Most if not all of those slow lookup functions contain a volatile INDIRECT() function. This defeats Excel's "smart" recalculation engine and forces all of those functions (including all of those slow linear lookups mentioned) to recalculate with every single calculate event. I would go to some lengths to get rid of all of these INDIRECTS() so that these functions are not volatile.
    3) I see single cell mega-formula array functions that duplicate effort. There are often parts of these formulas that are repeated for each copy of the formula. When you have thousands of formulas repeating the same array calculations, that represents a significant amount of extra effort. I would spend some time with these array formulas and see what calculations are being repeatedly performed, and move those calculations to helper ranges. These helper ranges only need to be calculated once per calculate event rather than 1000's of times.

    Those are three things that I see that are common in slow spreadsheets. I don't know what you will need help with. I have not spent a lot of time reverse engineering your spreadsheet, so I don't fully understand it, nor do I have any specific recommendations. These edits could become significant edits, too. There could be some value in focusing on specific tasks and parts of the file rather than try to work on the entire thing at once. As irritating as it is, it might even be better to start over from the beginning and structure the file completely differently (for example, it might become apparent that it will be better to design your language database as a single database in a single tab rather than having separate tabs for each language).

    That's what I see. Look at your file, consider what you need the file to do, what each step of that process looks like, and then let's see about making the overall process more efficient.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    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,926

    Re: Excel hangs due to many formulas, is it possible to create a more efficient process?

    wow that took ages just to load (minutes) - I almost had to stop the loading!!

    I agree fully with what MrShorty says. I think your entire file would be considerably simplified if you had ALL data in 1 sheet (the recognized standard method for data collection). You would then probably eliminate all of those volatile INDIRECT functions.
    Helper columns can also go a long way to keeping formulas simpler, easier to understand and edit, as well as speeding things up.. For instance, in your data sheet, you could have a helper that looks at Test B4, and only marks those records for consideration - all others will be ignored, so could also eliminate the volatile ARRAY functions
    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

  4. #4
    Registered User
    Join Date
    06-20-2017
    Location
    Europe
    MS-Off Ver
    MS Office 2016
    Posts
    20

    Re: Excel hangs due to many formulas, is it possible to create a more efficient process?

    Hi MrShorty and FDibbins!

    First of all, thanks a lot for taking the time to reply.

    I guess that my major mistake was focusing on solving each tiny problem and then trying to put it all together. During this week I've been working in the file with your advices (mainly, erasing the INDIRECT functions, compiling all the languages in one sheet and reducing the number of arrays) and even though the file still slows my PC, at least Excel doesn't stop working. Now it is functional and allows me to work with it.

    Again, thanks to both of you for your help and tips!

  5. #5
    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,926

    Re: Excel hangs due to many formulas, is it possible to create a more efficient process?

    If you could share your revised file, maybe we could take another look and see if we can find some more tweaks?

    Also, thanks for the rep
    Last edited by FDibbins; 05-17-2018 at 11:37 AM.

  6. #6
    Registered User
    Join Date
    06-20-2017
    Location
    Europe
    MS-Off Ver
    MS Office 2016
    Posts
    20

    Re: Excel hangs due to many formulas, is it possible to create a more efficient process?

    Hi FDibbins, sorry for the late reply and thanks for your interest. Find here the file. As I said, some flaws remain.

    To get rid of the INDIRECT formulas, I compiled all the languages sheets in just one. The main idea for columns C and F is to get words from different languages from sheet 'Languages' and also their value (known because I have previously worked with such words).

    Sheet 'TEST' column C shows single words, column F combined words (which I haven't managed to get yet: I want to display the terms with more than one word for the chosen language).
    Sheet 'TEST' column I displays relevant words from column C and new words (that are included handly, overwriting cells where the formula is 0).
    Sheet 'TEST' column L brings terms from column A in sheet KWs Comb. Once there are new words, formula in column A must be dragged until the highlighted cell (to get all the possible combinations).
    Back to sheet 'TEST', columns O, R and U are automatic combinations.
    Sheet 'TEST' column Z concatenates all the terms and the last combinations is shown in cell D4.

    If you have any more suggestions, feel free to say them. I will be very grateful!
    Attached Files Attached Files

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

    Re: Excel hangs due to many formulas, is it possible to create a more efficient process?

    While it is improved, I still see the same issues as I saw in the previous version:

    1) All of the lookups are still slow, linear lookups (fourth argument of VLOOKUP() is FALSE or 0 and 3rd argument of MATCH() is 0). Some of these lists look like they are sorted. In those cases, it might be as easy as replacing the 0/FALSE value with 1/TRUE. In other cases, you may still want to spend some time with the lookup column/row to get it sorted so that you can use a binary lookup.
    2) Like INDIRECT(), OFFSET() is also a volatile function. You might look at replacing these OFFSET()s with INDEX() functions. INDEX() is mostly not volatile, though it may still calculate more often than needed.
    3) I still see a lot of duplicated effort. For example, each copy of the functions in column C and D repeats the "which column contains the information for the language in C4" lookup. One quick suggestion would be to move this lookup into a helper cell (maybe B4). =MATCH($C$4,Languages!1:1,0) in B4 (or wherever you choose to put it). Then replace all of those MATCH() functions in C and D with a reference to this helper cell. Now Excel only needs to determine which columns to pull data from once rather than thousands of times.

    Those are just examples of what I see. It looks like there is still room for improving the computation time/effort in this file.

  8. #8
    Registered User
    Join Date
    06-20-2017
    Location
    Europe
    MS-Off Ver
    MS Office 2016
    Posts
    20

    Re: Excel hangs due to many formulas, is it possible to create a more efficient process?

    Ok, so I got rid of all the OFFSET too and used INDEX instead. I also changed the MATCH functions with helper cells. But I'm afraid I don't understand point 1 of your suggestions, I'm sorry. As far as I know, I've been using the fourth argument of VLOOKUP (and third of MATCH) to get the exact number; if I don't use it, a different value is displayed. I'm sure I didn't understand its use correctly, I was wondering if you could explain it to me so I could get the best out of your advice.
    Attached Files Attached Files

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

    Re: Excel hangs due to many formulas, is it possible to create a more efficient process?

    Almost all of the lookup examples on the internet are for exact match, linear lookups like you are using. If your data are sorted (usually in ascending order), then you can use a binary search by changing the third argument of MATCH() to 1 [MATCH(lookup_value,lookup_array,1)] or by changing the 4th argument of VLOOKUP() to TRUE [VLOOKUP(lookup_value,lookup_table,return_column,TRUE)]. Of course, if your data are not sorted, then it is just a matter of sorting the lookup array before running the lookup.

    Wikipedia's page about binary search algorithm: https://en.wikipedia.org/wiki/Binary_search_algorithm
    An example I put together than shows how a VLOOKUP() works with the binary search option: https://www.excelforum.com/tips-and-...p-example.html

+ 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. Replies: 8
    Last Post: 06-01-2017, 04:26 PM
  2. Excel will not process any formulas!!
    By petrolh34d in forum Excel General
    Replies: 5
    Last Post: 05-13-2017, 02:18 PM
  3. Create Macro/ Process to Send from Excel to Word Template
    By phiko73 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-02-2016, 12:55 PM
  4. [SOLVED] How can I make VBA process more efficient?
    By pholt33 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-05-2015, 01:55 PM
  5. Excel hangs and fails but only next day, this does involve formulas and macros....
    By Wannabeanexpert in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 01-29-2014, 01:07 AM
  6. Most efficient way to script to automate a long process?
    By Arcaklar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-21-2013, 11:55 PM
  7. Cube formulas either don't refresh complete or excel hangs when called from VBA
    By lev_myskin in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-23-2011, 03:54 PM

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