ExcelTips (Ribbon Interface)

# Calculating Only the Active Workbook

Please Note: This article is written for users of the following Microsoft Excel versions: 2007 and 2010. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Calculating Only the Active Workbook.

Linda asked if there is a way to calculate only the active workbook. When a recalc is performed by Excel, it recalculates all her open workbooks, and if they are very large workbooks it can sometimes take over fifteen minutes to recalc. If she is able to limit what is recalculated, then the process will obviously run faster.

Unfortunately, there is no direct method to just calculate a particular workbook. You can, however, calculate just the active worksheet, if desired. First, set the recalculation mode to manual by following these steps:

1. Display the Excel Options dialog box. (In Excel 2007 click the Office button and then click Excel Options. In Excel 2010 display the File tab of the ribbon and then click Options.)
2. Click the Formulas area at the left of the dialog box. (See Figure 1.)
3. Figure 1. The Formulas options of the Excel Options dialog box.

4. In the Calculation Options section of the dialog box, make sure the Manual radio button is selected.
5. Click on OK.

Now the only time your workbook (actually, all your open workbooks) will be recalculated is when you press F9. If you want to recalculate only the current worksheet, then press Shift+F9.

Excel also provides macro functions that allow you to do any of these three things: calculate all open workbooks, calculate a specific worksheet in a workbook, or calculate a specified range of cells on a worksheet. With this knowledge you could create a macro that would loop through all the worksheets in a workbook and recalculate each of them.

The following macro sets the calculation mode to manual (so the other workbooks will not calculate) and then loops through and calculates each sheet of the active workbook.

```Sub CalcBook()
Dim wks As Worksheet
Application.Calculation = xlManual
For Each wks In ActiveWorkbook.Worksheets
wks.Calculate
Next
Set wks = Nothing
End Sub
```

If you believe that you may want to calculate different parts of your workbook at different times, you can expand the macro so that it will perform any type of calculation you may want:

```Sub CalcWhat()
Dim iAnsure As Integer

Application.Calculation = xlManual
iAnsure = InputBox("1 = Calculate A Used Range" _
& vbCrLf & _
"2 = Calculate This Worksheet" _
& vbCrLf & _
"3 = Calculate This Workbook" _
& vbCrLf & _
"4 = Calculate All Workbooks in Memory" _
& vbCrLf & vbCrLf & _
"Input Your Selection Number From Above" _
& vbCrLf & "Then Click OK", _
"Calculate What?", "Input Number Please", _
5000, 5000)

Select Case iAnsure
Case 1 'Range Only
Selection.Calculate
Case 2 'Worksheet Only
ActiveSheet.Calculate
Case 3 'Workbook Only
For Each wks In ActiveWorkbook.Worksheets
wks.Calculate
Next
Case 4 'All Open Workbooks
Application.CalculateFull
End
End Select
End Sub
```

This macro presents an input box that prompts the user as to which type of recalculation is desired. When the user enters a number from 1 to 4, the desired type of recalculation is performed.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (6752) applies to Microsoft Excel 2007 and 2010. You can find a version of this tip for the older menu interface of Excel here: Calculating Only the Active Workbook.

Related Tips:

Program Successfully in Excel! John Walkenbach's name is synonymous with excellence in deciphering complex technical topics. With this comprehensive guide, "Mr. Spreadsheet" shows how to maximize your Excel experience using professional spreadsheet application development tips from his own personal bookshelf. Check out Excel 2013 Power Programming with VBA today!

waseem    11 Mar 2015, 06:48
I want to make a micros vba excel project how it is possible .can you make it .what is the charge for this
contact me+919969619733
Eric Augusta    06 Mar 2015, 11:10
The CalcWhat macro crashes if the user clicks the Cancel button on the Input Box. This can be avoided by changing iAnsure variable from Integer to Variant data type.
David Unger    05 Mar 2015, 08:21
Chuck, that's an excellent tip, thanks!
Chuck Trese    02 Jul 2014, 09:14
I also had a similar problem where a macro in file1 is slowed down because for every step it took (every time it wrote anything into a cell), file2 recalculated hundreds of thousands of very complex formulas. With today's computers, each such recalculation takes less then one second, but since the macro in file1 has hundreds of steps, it becomes very annoying - especially if I'm running the macro in file1 in front of an audience.

Here is the solution I use. Put this code in the worksheet that is doing all the unnecessary calculation:

Private Sub Worksheet_Activate()
Me.EnableCalculation = True
End Sub

Private Sub Worksheet_Deactivate()
Me.EnableCalculation = False
End Sub

This automatically turns off calculation for that sheet whenever you are not using it, but automatically turns it back on whenever you are using it.

If you would rather turn off calculation for the whole workbook, then put this in the "ThisWorkbook" code module of the file that is doing all the unnecessary recalculation:

Private Sub Workbook_Activate()
For Each ws In ThisWorkbook.Worksheets
ws.EnableCalculation = True
Next ws
End Sub

Private Sub Workbook_Deactivate()
For Each ws In ThisWorkbook.Worksheets
ws.EnableCalculation = False
Next ws
End Sub

If this method fits your scenario (a small number of troublesome files that you can add macros to), then I highly recommend it. The beauty of this method is that you never have to think about it! Once you implement this, it is fully automatic from then on. No extra steps are necessary, no manual calculations, and you will never accidentally leave calculation turned off.
Duncan Philps-Tate    16 Jul 2012, 05:00
Good tip.

But it leaves me wondering what Linda is doing with so many workbooks or such complicated structures that it takes 15 minutes to recalculate! I can remember that in the days of 386 chips when hard disks were measured in megabytes and not terabytes - but these days?

Maybe there's also a message about structure and inter-connection lurking there...
John    15 Jul 2012, 18:16
Great tip again Allen, I was working on a large WB with too many sumproduct formulas and needed exactly the calcwhat routine!

 *Name: Email: Notify me about new comments ONLY FOR THIS TIP Notify me about new comments ANYWHERE ON THIS SITE Hide my email address *Text: *What is 4+5 (To prevent automated submissions and spam.)

# Our Company

Sharon Parq Associates, Inc.

# Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2013)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2013)

Excel Products

Word Products

# Our Authors

Author Index

Write for Tips.Net