No debug option in VBA runtime error

2020-03-26 03:23发布

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.

screenshot of error -

Code is as follows -

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

Screenshot of the error http://imgur.com/gC32z74

enter image description here

2条回答
Deceive 欺骗
2楼-- · 2020-03-26 03:54

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.

查看更多
爷、活的狠高调
3楼-- · 2020-03-26 04:11

In VBA editor, Tools->Options... menu, General tab in the resulting dialog, set "Break on All Errors":

enter image description here

查看更多
登录 后发表回答