エラー オブジェクト (Excel)

セル範囲のスプレッドシート エラーを表します。

注釈

このオブジェクトは、セルを 1 つだけ含む範囲に対して動作します。

Error オブジェクトを返すには、Errors オブジェクトの Item プロパティを使用します。

Error オブジェクトが返されたら、Value プロパティを Range オブジェクトの Errors プロパティと組み合わせて使用して、特定のエラー チェック オプションが有効になっているかどうかをチェックできます。

注:

Error オブジェクトと Visual Basic のエラー処理機能と混同しないように注意してください。

次の例では、セル A1 に空白セルを参照する数式を作成し、 Item (index) を使用して状況を示すメッセージを表示します。ここで、 index はエラーの種類を識別します。

Sub CheckEmptyCells() 
 
 Dim rngFormula As Range 
 Set rngFormula = Application.Range("A1") 
 
 ' Place a formula referencing empty cells. 
 Range("A1").Formula = "=A2+A3" 
 Application.ErrorCheckingOptions.EmptyCellReferences = True 
 
 ' Perform check to see if EmptyCellReferences check is on. 
 If rngFormula.Errors.Item(xlEmptyCellReferences).Value = True Then 
 MsgBox "The empty cell references error checking feature is enabled." 
 Else 
 MsgBox "The empty cell references error checking feature is not on." 
 End If 
 
End Sub

プロパティ

関連項目

サポートとフィードバック

Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。