Error message when you use the Range.Calculate method to calculate formulas in an Excel workbook: "Run-time error '1004'" (825011)
The information in this article applies to:
- Microsoft Office Excel 2003
- Microsoft Excel 2002
SYMPTOMSWhen 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 CAUSEThis behavior may occur if the range that you are trying to calculate contains only part of an array range.WORKAROUNDMicrosoft 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.
Modification Type: | Major | Last Reviewed: | 10/11/2006 |
---|
Keywords: | kbnofix kberrmsg kbprb KB825011 kbAudEndUser |
---|
|