Errors Object (Excel)
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

Errors Object (Excel)

Office 2010

Represents the various spreadsheet errors for a range.

Use the Errors property of the Range object 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." 
 MsgBox "Cell A1 is a number." 
 End If 
End Sub
© 2015 Microsoft