禁用特定事件
我正在使用一个button来切换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
如何在不禁用Change
情况下禁用SelectionChange
?
不完全确定为什么你想要禁用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_Enabled
的值以启用或禁用事件中的代码。