Excel Macro Manual Calculation

Posted on  by 

Active1 year, 5 months ago

In excel I have a worksheet with over 30,000 rows. Sample data is shown in the image below. About a dozen of the columns have formulas which really slow down the work whenever I update a cell. I would like to use VBA code to turn off automatic formula calculation for only 5 columns (see columns in red in example). The formulas in the columns in yellow would run all the time. I would then like to create a macro that calculates the formula in the red columns whenever pressed.

I tried looking for some options in the formula ribbon but wasn't successful.

May 03, 2002  0 Thread(s) Here's another thought. Get the setting of the end-user when they open the workbook. Then set Excel to manual and when they close the workbook, return Excel the user's original setting. I used automacros, these go in a normal module: Make sure your private command is at the top of the module. The macro would then automatically calculate the 5 columns that are disabled whenever pressed. I've modified my question to include a screenshot with some sample data. – Danny Apr 10 '18 at 1:29.

Pᴇʜ
32.5k6 gold badges30 silver badges56 bronze badges
DannyDanny

2 Answers

  1. It’s a good practice to set your calculations to manual at the beginning of macros and restore calculations at the end of macros. If you need to recalculate the workbook you can manually tell Excel to calculate. Turn Off Automatic Calculations. You can turn off automatic calculation with a macro by setting it to xlmanual.
  2. Worksheet.Calculate method (Excel); 2 minutes to read +1; In this article. Calculates all open workbooks, a specific worksheet in a workbook, or a specified range of cells on a worksheet, as shown in the following table. Expression A variable that represents a Worksheet object.
  3. To set the calculation mode to manual, proceed to the Ribbon, select the Formulas tab and then find the Calculation grouping on the tab. Click on the Calculation Options button and select you guessed it Manual. This process is pictured to the below. Once manual is engaged, Excel will only recalculate when you tell it to.
  4. If you have Excel VBA macro code that runs slow, the chances are it's caused by Excel having to recalculate at each line of code. Deleting rows is one of many things that can become painfully slow. This can be overcome very easily by switching Excel into manual calculation before your code runs.

If you are creating a macro

But if you just want to enable and disable.. Go to the menu (from the ribbon) Formulas / Calculation Options and select Automatic or Manual as desired.

Manual
Dr YunkeDr Yunke

Instead of turning off calculation for a few columns, better to use a macro that calculates your resource-intensive formula and then saves the result as a value. You can even get it to only process blank cells or #N/A cells in the event that you only need to process things that didn't previously return a result. Just today I did the same for a computationally expensive FuzzyMatch routine I've written.

However, if your formulas are doing something such as crunching data via SUMPRODUCT or doing lookups on very large arrays, chances are you can optimize them so that they run in a fraction of the time, and thus completely avoid the need to selectively recalculate your sheet. And if those formulas are Volatile - or downstream of volatile functions - then chances are you can use non volatile formulas that stop your spreadsheet recalculating at the drop of a hat.

For faster SUMPRODUCT alternatives, see my answer at Optimizing Excel formulas - SUMPRODUCT vs SUMIFS/COUNTIFS

For much faster lookups, see my blog post at http://dailydoseofexcel.com/archives/2015/04/23/how-much-faster-is-the-double-vlookup-trick/

For more on volatility - including how to avoid it - see my blog post at https://chandoo.org/wp/2014/03/03/handle-volatile-functions-like-they-are-dynamite/

Excel Macro Manual Calculation Examples

For more suggestions, edit your post to include information on the formulas you are using, including how many formulas, what size ranges they reference, and what you're trying to achieve with them.

jeffreyweirjeffreyweirExcel Macro Manual Calculation

Excel Macro Manual Calculation 2016

3,9721 gold badge10 silver badges23 bronze badges

Excel Macro Manual Calculation Formula

Not the answer you're looking for? Browse other questions tagged excelvbaexcel-vbaexcel-formulacalculated-columns or ask your own question.

Coments are closed