VBA跨步跳过For循环



我正在开始使用这个"向导"文件来自动执行一些Excel(2016)任务,我遇到了VBA(7.1)中的Step into工具的问题。下面是我的代码:

Public LastInitial As Integer
Sub FormatRecipeFile()
    'Get the row number of the last 
    'initial listed in column D:
    LastInitial = Range("D" & Rows.Count).End(xlUp).Row
    'Prints "9" in cell F5:
    Range("F5").Value = LastInitial
    'The first initial is cell D3, so set j to 3:
    For j = 3 To LastIntitial
        'Set each intial to a new value:
        Range("D" & j).Value = Range("D" & j).Value & " (done)"
    Next j
End Sub

公共变量必须是公共的,以便将来使用。在F5中打印"9"是我检查For循环中是否有需要循环的项的方式。

问题是,当按下F8时,每行代码都被完美地执行,它甚至突出显示"For j = 3 To LastInitial",但当我再次按下F8时,它跳到"End Sub",而没有在For循环中运行任何内容。

你好,看来你在

这行有一个打字错误
For j = 3 To LastIntitial

应该是

For j = 3 To LastInitial

最新更新