- 2 minutes to read
If a cell contains a formula that cannot be calculated correctly, the cell's value (CellRange.Value) is of the error type (the CellValue.IsError property value is true). To access information on an error contained in a cell, use the members of the ErrorValueInfo object returned by the CellValue.ErrorValue property. The ErrorValueInfo.Type returns the ErrorType enumeration member that specifies the error type, the ErrorValueInfo.Name property returns the error name displayed in a cell, and the ErrorValueInfo.Description property returns the cause of the error.
Division by zero!
cell.Formula = "= 10/0"
cell.Formula = "= A1/B2", the B2 cell is blank
Function does not exist.
cell.Formula = "= FALS" - The function name used in the formula is not spelled correctly.
cell.Formula = "=SUM(A1B2)" - A colon (:) is missing in the cell range reference.
The value is not available to a function or formula.
cell.Formula = "= NA()"
cell.ArrayFormula = "=SUM(A1:A5*A1:B3)" - An array formula's arguments are arrays consisting of different numbers of elements.
The specified intersection includes two ranges that do not intersect.
cell.Formula = "=SUM(A1:A5 E6:E8)" - The specified ranges do not intersect, so the sum cannot be calculated.
Invalid numeric values in a formula or function.
cell.Formula = "=SQRT(-16)" - The square root of a negative number cannot be calculated.
Cell reference is not valid.
A formula uses a reference to a cell, and then the column containing this cell is deleted:
cell.Formula = "=5+D2";
The value used in the formula is of the wrong data type.
cell.Formula = @"= SUM(""text"", 6)" - The SUM function requires numeric arguments.
A formula refers to a blank cell that is not actually empty (it contains an empty string):
worksheet["A1"].Value = "";
cell.Formula = "= A1 + 5";
To fix the error in this case, specify an empty value for a cell as shown in the How to: Clear Cells of Content, Formatting, Hyperlinks and Comments example.