相关疑难解决方法(0)

转到块不工作VBA

简介:我想做一些基本的错误处理

问题:当我单步执行代码时,即使没有错误,我的"错误"块数据也会运行

- 我对VBA中的错误处理很新,并且不明白为什么错误块中的代码是在我指导代码进入块的情况下运行的.提前致谢!

代码:

Function getReports()

    startJournal = Sheets("Runsheet").Range("B5")
    endJournal = Sheets("Runsheet").Range("E5")

    If startJournal = 0 Or endJournal = 0 Then

        GoTo Error

    End If

    'bunch of code

Error:
    MsgBox ("Error Statement")

End Function
Run Code Online (Sandbox Code Playgroud)

error-handling excel vba excel-vba

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

标签 统计

error-handling ×1

excel ×1

excel-vba ×1

vba ×1