共用方式為


Excel) (錯誤物件

代表某個範圍的試算表錯誤。

註解

此物件適用於僅包含一個儲存格的範圍。

使用 Errors 物件的 Item 屬性來傳回 Error 物件。

傳回 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 支援與意見反應