Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何调试循环/在循环中向前移动?(VBA)_Vba_Excel_Loops_Debugging_Breakpoints - Fatal编程技术网

如何调试循环/在循环中向前移动?(VBA)

如何调试循环/在循环中向前移动?(VBA),vba,excel,loops,debugging,breakpoints,Vba,Excel,Loops,Debugging,Breakpoints,我正在尝试调试VBA中的多层循环。我想看到循序渐进的循环过程,但只能很好地进入循环。(即,循环从1到120,我希望看到它在I=110时运行) 我知道我可以在中断模式下使用F8键,但是有没有一种方法可以在循环中前进而不必按住F8键,直到我到达循环中需要的点 谢谢只是一些选项: 添加一个手表和断开值(必须以正确的值为目标) 在110启动相关循环 在相关循环中添加带有STOP的If子句;仅举几个例子 带有If子句的示例: Option Explicit Public Sub test() D

我正在尝试调试VBA中的多层循环。我想看到循序渐进的循环过程,但只能很好地进入循环。(即,循环从1到120,我希望看到它在I=110时运行)

我知道我可以在中断模式下使用F8键,但是有没有一种方法可以在循环中前进而不必按住F8键,直到我到达循环中需要的点

谢谢

只是一些选项:

  • 添加一个手表和断开值(必须以正确的值为目标)
  • 在110启动相关循环
  • 在相关循环中添加带有
    STOP
    If
    子句;仅举几个例子
  • 带有
    If
    子句的示例:

    Option Explicit
    
    Public Sub test()
        Dim i As Long
        For i = 1 To 120
            If i = 110 Then
                Debug.Print i
                Stop
            End If
        Next i
    End Sub
    

    如果我理解正确,也许你可以这样做:

    Sub loop120()
    Dim i As Integer
    
    i = 0
    Do
    i = i + 1
    
        If i = 110 Then
            'Code goes here for when the loop has executed 120 times
            MsgBox "This is the 110th loop"
            '<---- stick a break point on your next line of code
        End If
    
    
    Loop
    
    End Sub
    
    子循环120()
    作为整数的Dim i
    i=0
    做
    i=i+1
    如果i=110,那么
    '当循环执行120次时,代码在这里
    MsgBox“这是第110个循环”
    
    '在120开始循环?或者在价值表上设置一个中断。。。或者,即使i=120,也要停止……有不同类型的循环,并且可以采用不同的方式将它们“分层”(我想你的意思是嵌套的)。在不知道自己拥有什么的情况下,无法确定自己能做什么。(见“”)