Errors Property

Microsoft Excel Visual Basic

expression.Errors

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

Reference the Errors object to view a list of index values associated with error checking options.

Example

In this example, a number written as text is placed in cell A1. Microsoft Excel then determines if the number is written as text in cell A1 and notifies the user accordingly.

Sub CheckForErrors()

    Range("A1").Formula = "'12"

    If Range("A1").Errors.Item(xlNumberAsText).Value = True Then
        MsgBox "The number is written as text."
    Else
        MsgBox "The number is not written as text."
    End If

End Sub