Error オブジェクト (Excel)

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

注釈

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

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

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

注:

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

次の例では、空のセルを参照するセル A1 に数式を作成し、 Item (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 のサポートおよびフィードバックを参照してください。