小编Com*_*617的帖子

在条件格式中使用UDF时,VBA编译器不会破坏/捕获错误并且不会显示错误消息

看到新的发展.

我在Excel中有一个奇怪的问题.我有一个Worksheet_Change我正在使用的事件,我正在尝试调试它.我保存程序并重新打开它,突然之间编译器没有打破错误.事实上,它根本没有破坏!我会在分队的头部(以及接下来的三条线路)进行休息,这样就不会发生.我想也许事件没有启用......所以,我把一个消息框作为第一行代码之一.弹出消息框....即使在它的行上有中断.

这发生在另一个宏的特定行上之前,我尝试将所有内容复制到.txt文件中并将其粘贴回我的程序的早期版本.这工作了几个月,但问题现在又回来了.

编码并不是很重要,但我会将其粘贴在下面,以便进行踢腿和傻笑.这是在没有错误的情况下中止,我删除所有"错误"或不.我已经将代码剪切并粘贴到一个新的子中,它工作正常.我还检查了选项并检查了"中断所有错误".什么都没有,即使是未定义的调用也不会抛出错误,会阻止程序中止.

Private Sub Worksheet_Change(ByVal target As Range)
Application.EnableEvents = False
Dim aVar() As String
Dim iVar As Integer
On Error GoTo 0

MsgBox "you changed something" 'this is a msgbox that does pop up during execution, verifying that the sub did in fact, run. 
Call iRandomNonsense 'this is a sub that does not exist which the compiler does not tell me about any more.

If target.Columns.Count = 1 Then
    Select Case target.Column
    Case 2
        If …
Run Code Online (Sandbox Code Playgroud)

error-handling excel vba excel-vba internal-compiler-error

6
推荐指数
1
解决办法
489
查看次数