[英]Excel crashes after triggering macro by clicking a cell
As the title mentions, the macro crashes after clicking a cell to trigger it. 如标题所述,单击单元格触发宏后宏会崩溃。 I have used this for 2 months with no crashes or other problem but it crashes all the time today.
我已经使用了2个月,没有崩溃或其他问题,但是今天它一直崩溃。 Then, I tried to run the macro by calling the same function in the Immediate Window and it ran properly.
然后,我尝试通过在立即窗口中调用相同的函数来运行宏,并且该宏正常运行。 I am wondering why and how to solve this.
我想知道为什么以及如何解决这个问题。
For your reference, here is my code in that worksheet: 供您参考,这是该工作表中的代码:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$2" Then
reviewActiveSheetOrder
End If
End Sub
reviewActiveSheetOrder
is the function I want to run, and it can run properly if I call it in the Immediate Window. reviewActiveSheetOrder
是我要运行的函数,如果我在“即时窗口”中调用它,它可以正常运行。
Try to disable events before calling reviewActiveSheetOrder
and see if that helps... 尝试在调用
reviewActiveSheetOrder
之前禁用事件,看看是否有帮助...
Also place Cancel = True
before calling another procedure as after double clicking a cell, you are in the Edit Mode
, maybe that is causing the issue. 另外,在调用另一个过程之前,将
Cancel = True
放置在双击单元格之后,即您处于“ Edit Mode
,这可能是导致问题的原因。
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address = "$A$2" Then
Cancel = True
Application.EnableEvents = False
reviewActiveSheetOrder
Application.EnableEvents = True
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.