Forum Discussion
JWorthers
Dec 08, 2023Copper Contributor
Need to speed up Spreadsheet
Hi All, I have a very large dataset in Sheet2. This dataset has a bunch of formula applied based on inputs on Sheet1. On Sheet1, I have some standalone calcs and also some inputs and graphical o...
NikolinoDE
Dec 08, 2023Gold Contributor
Your approach is on the right track, but you might want to consider a few additional optimizations. The issue could be complex formulas, large datasets, or dependencies that are still causing delays. Here's an updated version of your code with some additional tweaks:
Vba code (is untested):
Sub CalcSheet2()
Application.EnableEvents = False
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
' Calculate only Sheet2
Sheets("Sheet2").Calculate
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
In this version, I've included Application.ScreenUpdating to prevent the screen from updating during the calculation, which can improve performance.
You can assign this macro to a command button in your Excel sheet, and then run it whenever you want to manually trigger the calculation for Sheet2. This way, the calculations for Sheet2 won't be happening in the background every time there's any change on Sheet1.
Remember, the effectiveness of this depends on the nature of your calculations and formulas. If your formulas are still complex or dependent on large datasets, the calculation time might still be significant. Consider optimizing your formulas or breaking down your data into more manageable chunks if possible.
Additionally, if you are working with a very large dataset and the performance issue persists, you might want to explore more advanced techniques, such as using PivotTables, summarizing data differently, or using a database solution. The text and steps were edited with the help of AI.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and Like it!
This will help all forum participants.
- JWorthersDec 08, 2023Copper Contributor
Thanks for the response.
Sheet2 has some complex formula, some rather hefty stuff and there are probably some efficiencies to made just by tidying it up.
I think you've addressed my general concern, which is in fact that I'm trying to shortcut the issue.
In my simple mind I figured that by turning off large computations (until necessary) this would speed up the rest of the workbook, but perhaps I need to go back and find a way to be more efficient with my formulas.
Link below to the spreadsheet that I'm using to test the VBA code. This includes some random formulas to intentionally weigh down Sheet2 to represent my issue. Feel free to see if you can come up with a solution using macros.
- NikolinoDEDec 09, 2023Gold Contributor
I appreciate the additional context. I reviewed the file you provided. It's a good example, and indeed, large datasets and complex formulas can lead to performance issues.
Your instinct about optimizing the formulas is on point. Here are a few suggestions:
- Check for Volatile Functions: Certain functions, such as INDIRECT, OFFSET, and CELL, are volatile and can significantly slow down your workbook. If possible, try to minimize the use of these functions.
- Use Named Ranges: Instead of referencing entire columns like Sheet2!A:A, try to use named ranges that encompass only the necessary data. This can help Excel perform calculations more efficiently.
- Array Formulas: Some formulas in your Sheet2 use entire column references. Consider using array formulas with specific ranges to reduce the number of cells being calculated.
- Avoid Full Column References: Refrain from using full column references if you don't need them. For example, instead of =IF(A:A="Yes", B:B, ""), use =IF(A1:A100="Yes", B1:B100, "") if your data only goes up to row 100.
While macros can help control when calculations occur, optimizing the formulas themselves will have a more significant impact on overall performance.