Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Calculations may not occur in an Excel workbook that has many formulas when you use the Calculate method to calculate formulas or after you press SHIFT+F9 to calculate formulas


View products that this article applies to.

Symptoms

When you calculate formulas in a workbook that contains many formulas in Microsoft Excel 2002 or in Microsoft Office Excel 2003, the calculations may not occur.

This issue may occur when either of the following conditions is true:
  • You use the Calculate method in a Microsoft Visual Basic for Applications (VBA) macro to calculate formulas.
  • You press F9 to calculate formulas in all open workbooks that have changed since the last calculation. Then, you press SHIFT+F9 to calculate formulas in the active worksheet that have changed since the last calculation. When you press F9 again to calculate formulas in all open workbooks, the formulas in all open workbooks are not calculated.

↑ Back to the top


Workaround

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. To work around this problem, use the UsedRange property when you calculate formulas. To do this, use one of the following methods depending on how you calculate formulas.

You use the Calculate method in a VBA macro to calculate formulas

If you use the Calculate method in a VBA macro to calculate the formulas in a workbook, use the UsedRange property.

For example, you use one of the following Calculate methods:
  • ActiveSheet.Calculate
  • Worksheets("Sheet1").Calculate
Instead, use the UsedRange property as follows:
  • ActiveSheet.UsedRange.Calculate
  • Worksheets("Sheet1").UsedRange.Calculate

You press SHIFT+F9 to manually calculate formulas

If you press SHIFT+F9 to manually calculate formulas in the active worksheet, create a Microsoft Visual Basic for Applications (VBA) macro to capture the keystrokes and to programmatically use the UsedRange property.

To do this, follow these steps:
  1. Open a new workbook in Excel.
  2. On the Tools menu, point to Macro and then click Visual Basic Editor. Or, press ALT+F11 to open the Visual Basic Editor.
  3. In the Project window, double-click ThisWorkbook.
  4. Paste or type the following VBA code in the module code sheet:
    Private Sub Workbook_Open()
     Application.OnKey key:="+{F9}", procedure:="Calcit"
    End Sub
    
    Sub Calcit()
     ActiveSheet.UsedRange.Calculate
    End Sub
    
  5. Press ALT+TAB to switch back to the worksheet.
  6. On the File menu, click Properties.
  7. On the Summary tab, type the title of the add-in that you want to appear in the Add-Ins dialog box, and then click OK.
  8. On the File menu, click Save As.
  9. In the Save as type box of the Save As dialog box, click Microsoft Office Excel Add-in (*.xla), type a name for the add-in in the File name box, and then click Save.

    Note Save the add-in in the following folder:
    C:\Program Files\Microsoft Office\Office11\Library
  10. To load the new add-in, follow these steps:
    1. On the Tools menu, click Add-Ins.
    2. Click to select the check box for the new add-in, and then click OK to close the Add-Ins dialog box.

↑ Back to the top


More information

This issue does not occur in Excel 2000. If you use this workaround in Excel 2000, the workaround will not cause any problems. When you use the UsedRange property, you may experience the same issues that are experienced with the Range property. For more information about the issues with the Range property, click the following article number to view the article in the Microsoft Knowledge Base:
292476 Run-time error when you use the Range.Calculate method in Excel


For more information about Excel add-ins, visit the following Microsoft Web site:

↑ Back to the top


Keywords: KB919127, kbprb, kbexpertisebeginner, kbtshoot, kbvba, kbautomation, kbformula, kbprogramming

↑ Back to the top

Article Info
Article ID : 919127
Revision : 5
Created on : 1/12/2007
Published on : 1/12/2007
Exists online : False
Views : 298