Turning off calculations in Excel VBA during a macro prevents Excel from recalculating formulas after every change, which significantly speeds up macro execution when working with large datasets or complex formulas. This is done by setting the Application.Calculation property to xlCalculationManual before running your code and restoring it to xlCalculationAutomatic afterward. No additional tools or add-ins are needed—just access to the VBA editor in Excel.
What You'll Need
- Microsoft Excel (any recent version that supports VBA, such as Excel 2010 or later)
- Access to the VBA editor (press ALT + F11 to open it)
- A macro (Sub procedure) that you want to run faster
Step-by-Step
- Open your Excel workbook and press ALT + F11 to launch the VBA editor.
- In the VBA editor, locate the module where your macro is stored or insert a new module via Insert > Module.
- At the very beginning of your macro code, add the line:
Application.Calculation = xlCalculationManual - Place your existing macro logic below this line.
- Just before the End Sub statement, add the line:
Application.Calculation = xlCalculationAutomatic - Optional: Add error handling to ensure calculations are re-enabled even if the macro fails. Use:
- On Error GoTo CleanUp
- CleanUp: Application.Calculation = xlCalculationAutomatic
- Save your workbook as a macro-enabled file (.xlsm) to preserve the VBA code.
- Run the macro using ALT + F8, select your macro, and click Run, or assign it to a button.
- Verify that calculations were suspended by checking the Formulas tab > Calculation Options—it should show Manual during macro execution and return to Automatic afterward.
Common Mistakes
- Forgetting to turn calculations back on, leaving Excel in manual mode until manually reset or the file is reopened.
- Placing the calculation toggle inside loops or conditional blocks where it might not execute if an error occurs early.
- Using
Application.CalculateorApplication.ScreenUpdating = Falseas a substitute—these do not disable automatic formula recalculation. - Assuming that turning off calculations also turns off volatile functions like NOW() or RAND(); these still recalculate unless volatile functions are avoided or handled separately.
- Not testing the macro on a copy of the data first, risking unintended results if the macro behaves differently under manual calculation.
Tips
- Always use error handling (as shown in Step 5) to guarantee that calculation mode is restored, even if the macro crashes.
- Combine this with
Application.ScreenUpdating = Falsefor even greater performance improvements when modifying cells or formatting. - If you need to force a calculation at a specific point during the macro (e.g., after updating inputs), use
Application.CalculateorRange.Calculatewhile calculations are still set to manual. - Consider storing the original calculation state in a variable if you’re unsure whether it was Automatic or Manual to begin with, then restore that exact state.
- For very large operations, test performance with and without calculation suspension to measure the actual gain.
Troubleshooting
- Calculations remain off after macro runs: This usually means the macro ended abruptly due to an error before reaching the reset line. Reopen the workbook (which resets to Automatic by default) or manually set Formulas > Calculation Options > Automatic. Then add error handling to your macro.
- Macro runs slowly despite turning off calculations: Check if you’re still triggering calculations via volatile functions, external links, or add-ins. Use the Formula Auditing tools to trace dependencies.
- Getting a 'Method or property not supported' error: This can occur if you’re using Excel in a restricted environment (like Excel Online) where VBA is not available. Confirm you’re using the desktop version of Excel.
- Formulas don’t update when expected: Remember that manual calculation means formulas won’t update until you trigger them. Press F9 to calculate the active worksheet, or Ctrl+Alt+F9 to force a full recalculation.
- Macro behaves differently with calculations off: Some macros depend on immediate formula results to make decisions. In such cases, calculate only the necessary ranges using
Range.Calculateinstead of disabling everything.
Frequently Asked Questions
Will turning off calculations affect charts or pivot tables?
Charts and pivot tables may not refresh automatically when their source data changes under manual calculation. You can refresh them manually or trigger a calculate event for specific objects if needed.
Is it safe to leave calculations off after the macro finishes?
No—leaving calculations off can lead to outdated formula results and confusion. Always restore xlCalculationAutomatic unless you have a specific reason and user awareness to keep it manual.
Can I turn off calculations for just one worksheet?
No, the Application.Calculation setting applies to the entire Excel application. However, you can calculate individual worksheets or ranges using Worksheet.Calculate or Range.Calculate while in manual mode.
Does this work in Excel for Mac?
Yes, the same VBA syntax works in Excel for Mac. Use ALT + F11 or Option + F11 to open the VBA editor, depending on your keyboard setup.
What’s the difference between this and enabling manual calculation via the ribbon?
Manually setting calculation mode via Formulas > Calculation Options affects all future actions until changed. Using VBA lets you toggle it temporarily and automatically just for the duration of your macro, then restore the original setting.
Will this interfere with other macros or user actions?
While calculations are off, any formula-dependent actions by the user or other macros will not update until calculation is turned back on or manually triggered. Avoid running long user-dependent processes during this window.