Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 禁用特定事件_Excel - Fatal编程技术网

Excel 禁用特定事件

Excel 禁用特定事件,excel,Excel,我正在使用按钮切换Application.EnableEvents: Sub Button1_Click() If ActiveSheet.Shapes("Button 1").TextFrame.Characters.Text = "Disable Events" Then ActiveSheet.Shapes("Button 1").TextFrame.Characters.Text = "Enable Events" Application.EnableEvents = F

我正在使用按钮切换Application.EnableEvents:

Sub Button1_Click()
If ActiveSheet.Shapes("Button 1").TextFrame.Characters.Text = "Disable Events" Then
    ActiveSheet.Shapes("Button 1").TextFrame.Characters.Text = "Enable Events"
    Application.EnableEvents = False
Else
    ActiveSheet.Shapes("Button 1").TextFrame.Characters.Text = "Disable Events"
    Application.EnableEvents = True
End If
End Sub

如何禁用
SelectionChange
而不禁用
Change

不完全确定您为什么要禁用
SelectionChange
,或者这会做什么

如果该部分中有代码,可以将其包装在If语句中

' Insert the following code into a new module: Module1
Public SelectionChange_Enabled As Boolean

' Example of your Worksheet_SelectionChange event's code
Public Sub Worksheet_SelectionChange(ByVal Target As Range)
    If SelectionChange_Enabled = True Then
    ' Your code
    End If
End Sub

您可以更改
SelectionChange\u Enabled
的值,以启用或禁用事件中的代码。

不完全确定您为什么要禁用
SelectionChange
或这将做什么

如果该部分中有代码,可以将其包装在If语句中

' Insert the following code into a new module: Module1
Public SelectionChange_Enabled As Boolean

' Example of your Worksheet_SelectionChange event's code
Public Sub Worksheet_SelectionChange(ByVal Target As Range)
    If SelectionChange_Enabled = True Then
    ' Your code
    End If
End Sub

您可以更改
SelectionChange\u Enabled
的值来启用或禁用事件中的代码。

太好了,谢谢!现在,当我想使用
Change
时,我不会意外触发
SelectionChange
。那太好了,谢谢!现在,当我想使用
Change
时,我不能意外触发
SelectionChange