VBA运行时错误中没有调试选项 [英] No debug option in VBA runtime error

查看:927
本文介绍了VBA运行时错误中没有调试选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用excel 2013.当出现运行时错误时,我没有得到任何调试选项。如何在运行时错误期间获得调试选项?

I am using excel 2013. I do not get any debug option when there is a runtime error. How can I get a debug option during runtime errors?

编辑 - 我已经意识到,仅在以下情况下我有这个问题。通常我得到调试选项(除了这种情况)。特别痛苦的是,它甚至没有告诉我错误是哪一行。

Edit - I have realized that I have this problem only in the following instance. Normally I am getting the debug option (except for this case). What is especially painful is that it doesn't even tell me which line the error is on.

错误的截图 -

代码如下 -

Option Explicit
Option Base 1

Sub doit()

Dim intRowCounter As Long
Dim intColCounter As Long
Dim parentFormula As String
Dim resultantFormulas As String

For intRowCounter = 1 To 100
    For intColCounter = 1 To 200

        'This is the line giving the error
        parentFormula = Right(parentFormula, Len(parentFormula) - 1)

    Next intColCounter
Next intRowCounter

End Sub

错误的截图 http://imgur.com/gC32z74

推荐答案

我遇到这个thr ead,因为我有一个电子表格,当宏没有得到一个调试选项时,一个错误。我发现如果我制作一个模块,并将相同的子文件放在模块而不是Worksheet中,那么当发生错误时,我会得到调试选项。

I came across this thread because I had a spreadsheet where I didn't get a debug option when a macro hit an error. I found that if I make a module and put the same sub in the module instead of the Worksheet then I get the debug option when an error occurs.

如果我将功能留在工作表中,我可以设置不同的选项。如果我把它留在打破未处理的错误,我只会收到一条错误消息,如果我使它打破所有错误或中断模块,那么当发生错误时,我得到调试选项。

If I leave the function in the Worksheet I can set the Options differently. If I leave it on "Break on Unhandled Errors" I only get an error message, if I make it "Break on All Errors" or "Break in Class Module" then I get the debug option when an error occurs.

这篇关于VBA运行时错误中没有调试选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆