打开工作簿时关闭Excel背景错误检查

8

我有一个Excel工作簿,里面有很多绿色的“错误检查”三角形。

是否有办法在打开工作簿时使用Excel VBA将其关闭?


2天前,我正在审核我的一份现有报告,发现它有很多那些三角形。我通过重构公式来摆脱它们。 - PowerUser
如果您选择了所有的值,请单击三角形并选择“忽略此错误”,它们都会消失。-或者-您可以修复错误,即更改值,使其不会这样做。 - Rick Henderson
5个回答

10

我认为这就是你要找的:

    Application.ErrorCheckingOptions.BackgroundChecking = False

对我有用。我将它放在 ThisWorkbook 宏页面内的 Private Sub Workbook_Open() 中。 - Rachcha

4
我找到了我想要的答案:
Sub Auto_Open()
    Application.ErrorCheckingOptions.BackgroundChecking = False 
End Sub

2
我通常把工作簿标签分成“数据”、“计算”和“演示”。因此,我不喜欢在“演示”标签中的表格中看到绿色的错误检查三角形。一种方法是保护该工作表...绿色检查消失了!(仅针对该标签)
如果您仍希望访问受保护的选项卡,则只需解锁所有单元格并在保护之前选择适当的保护选项。
我建议避免使用宏,因为这可能会影响用户在各个工作簿和标签中的设置。

0

只需使用这个:

With Application.ErrorCheckingOptions
    .BackgroundChecking = False
    .EvaluateToError = False
    .TextDate = False
    .NumberAsText = False
    .InconsistentFormula = False
    .OmittedCells = False
    .UnlockedFormulaCells = False
    .ListDataValidation = False
End With

如果您使用上述代码,它将永久关闭此功能,并适用于所有Excel文档。
但是,如果您只想对您的Excel文档执行此操作(而不是全部执行),请执行以下操作:
    '''''''''''''''' IN A MODULE '''''''''''''''''''
    Public AE_BackgroundChecking As Boolean
    Public AE_EvaluateToError As Boolean
    Public AE_TextDate As Boolean
    Public AE_NumberAsText As Boolean
    Public AE_InconsistentFormula As Boolean
    Public AE_OmittedCells As Boolean
    Public AE_UnlockedFormulaCells As Boolean
    Public AE_ListDataValidation As Boolean
    Public AE_EmptyCellReferences As Boolean
    ''''''''''''''''''''''''''''''''''''''''''''''''

    ''''''''''''''''' IN WORKBOOK OPEN EVENT '''''''''''''

    AE_BackgroundChecking = Application.ErrorCheckingOptions.BackgroundChecking
    AE_EvaluateToError = Application.ErrorCheckingOptions.EvaluateToError
    AE_TextDate = Application.ErrorCheckingOptions.TextDate
    AE_NumberAsText = Application.ErrorCheckingOptions.NumberAsText
    AE_InconsistentFormula = Application.ErrorCheckingOptions.InconsistentFormula
    AE_OmittedCells = Application.ErrorCheckingOptions.OmittedCells
    AE_UnlockedFormulaCells = Application.ErrorCheckingOptions.UnlockedFormulaCells
    AE_ListDataValidation = Application.ErrorCheckingOptions.ListDataValidation
    AE_EmptyCellReferences = Application.ErrorCheckingOptions.EmptyCellReferences

    With Application.ErrorCheckingOptions
        .BackgroundChecking = False
        .EvaluateToError = False
        .TextDate = False
        .NumberAsText = False
        .InconsistentFormula = False
        .OmittedCells = False
        .UnlockedFormulaCells = False
        .ListDataValidation = False
        .EmptyCellReferences = False
    End With
    ''''''''''''''''''''''''''''''''''''''''''



''''''''''''''''' IN WORKBOOK CLOSE EVENT '''''''''''''
Application.ErrorCheckingOptions.BackgroundChecking = AE_BackgroundChecking
Application.ErrorCheckingOptions.EvaluateToError = AE_EvaluateToError
Application.ErrorCheckingOptions.TextDate = AE_TextDate
Application.ErrorCheckingOptions.NumberAsText = AE_NumberAsText
Application.ErrorCheckingOptions.InconsistentFormula = AE_InconsistentFormula
Application.ErrorCheckingOptions.OmittedCells = AE_OmittedCells
Application.ErrorCheckingOptions.UnlockedFormulaCells = AE_UnlockedFormulaCells
Application.ErrorCheckingOptions.ListDataValidation = AE_ListDataValidation
Application.ErrorCheckingOptions.EmptyCellReferences = AE_EmptyCellReferences
'''''''''''''''''''''''''''''''''''''''''''''''''''''''

你的解决方案可能是有效的,但有点费力。 只需执行Application.ErrorCheckingOptions.BackgroundChecking = True,然后进行可能出现错误检查的操作,最后使用Application.ErrorCheckingOptions.BackgroundChecking = False重新激活它即可。 - micsky

-1
13年晚了,但是你可以在VBA中自己制作iferror语句而不会停止子程序。
On Error Resume Next
    'MyCode
If Err.Number > 0 Then
    'Code if error
Else
End If
On Error GoTo 0

根据目前的写法,你的回答不够清晰。请编辑以添加更多细节,以帮助其他人理解这如何回答所提出的问题。你可以在帮助中心找到更多关于如何撰写好回答的信息。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接