Share via


Errors Object

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Range
Aa661414.parchild(en-us,office.10).gifErrors
Aa661414.space(en-us,office.10).gifAa661414.parchild(en-us,office.10).gifError

Represents the various spreadsheet errors for a range.

Using the Errors object

Use the Errors property of the Range collection to return an Errors object.

Once an Errors object is returned, you can use the Value property of the Error object to check for particular error-checking conditions.  The following example places a number as text in cell A1 and then notifies the user when the value of cell A1 contains a number as text.

  Sub ErrorValue()

    ' Place a number written as text in cell A1.
    Range("A1").Formula = "'1"

    If Range("A1").Errors.Item(xlNumberAsText).Value = True Then
        MsgBox "Cell A1 has a number as text."
    Else
        MsgBox "Cell A1 is a number."
    End If

End Sub