Microsoft KB Archive/825011

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 17:08, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


Error message when you use the Range.Calculate method to calculate formulas in an Excel workbook: "Run-time error '1004'"

Article ID: 825011

Article Last Modified on 11/20/2006



APPLIES TO

  • Microsoft Office Excel 2007
  • Microsoft Office Excel 2003
  • Microsoft Excel 2002 Standard Edition



SYMPTOMS

When you use the Range.Calculate method to calculate formulas in a Microsoft Excel workbook, you may receive the following error message:

Run-time error '1004':

Calculate method of Range class failed

CAUSE

This behavior may occur if the range that you are trying to calculate contains only part of an array range.

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 behavior, calculate the entire array range. To do this, use the following Microsoft Visual Basic for Applications (VBA) macro code:

Sub CalcTheRange()

   'Replace Cell with the actual cell range in your workbook
   'For example, ("A2:F4")
   SafeCalcRange ThisWorkbook.Sheets("SheetName").Range("Cell:Cell")

End Sub
 

Sub SafeCalcRange(rng As Range)

   For Each cl In rng.Cells

      If cl.HasArray Then Set rng = Union(rng, cl.CurrentArray)

   Next cl

   rng.Calculate

End Sub

STATUS

This behavior is by design.

MORE INFORMATION

This behavior is consistent with user interface behavior because you cannot change part of an array range.

For more information about a design change in Excel for formula calculations, click the following article number to view the article in the Microsoft Knowledge Base:

825012 How formula calculations are performed in Excel 2002 or Excel 2003



Additional query words: XL2002 XL2003

Keywords: kbnofix kberrmsg kbprb KB825011