Welcome toExcel.Tips.Net
Tips.Net Home
ExcelTips Home
Ask an Excel Question
Make a Comment
ExcelTips FAQ
ExcelTips Premium
Learn Access Now
Free Printable Forms
Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips
Advertise on the
ExcelTips Site
Filtering Columns for Unique Values
Printing Multiple Worksheets on a Single Page
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:
If you are using a version of Excel prior to Excel 2007, follow these steps instead:
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 (2877) applies to Microsoft Excel versions: 97 2000 2002 2003 2007
Your Data, Your Way! Want the greatest control possible over how your data appears on the page? Excel's custom formats can provide that control, and ExcelTips: Custom Formats can unlock the secrets to creating your own custom formats.