Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.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
在嵌套的Excel VBA For…Next循环中,父级Next无法找到其For j=0到SpreadCount的 如果TypeName(ChainsDC(j,0)=“String”'测试错误 转到结束循环 其他: 对于i=0至RscSct …在这里做令人惊奇的事情(无循环) 接下来我 结束循环: 下一个问题是你的IF语句。你需要添加一个Then和一个End IF: For j = 0 to SpreadCount If TypeName(ChainsDC(j,0) = "String" 'testing for an error Goto EndLoop Else: For i = 0 to RscSct ...do amazing things here (no loops) Next i EndLoop: Next j '<<<PROBLEM j=0到SpreadCount的 如果TypeName(ChainsDC(j,0)=“String”**则** 转到结束循环 其他: 对于i=0至RscSct …在这里做令人惊奇的事情(无循环) 接下来我 **如果结束** 结束循环: 下一个j'_Vba - Fatal编程技术网

在嵌套的Excel VBA For…Next循环中,父级Next无法找到其For j=0到SpreadCount的 如果TypeName(ChainsDC(j,0)=“String”'测试错误 转到结束循环 其他: 对于i=0至RscSct …在这里做令人惊奇的事情(无循环) 接下来我 结束循环: 下一个问题是你的IF语句。你需要添加一个Then和一个End IF: For j = 0 to SpreadCount If TypeName(ChainsDC(j,0) = "String" 'testing for an error Goto EndLoop Else: For i = 0 to RscSct ...do amazing things here (no loops) Next i EndLoop: Next j '<<<PROBLEM j=0到SpreadCount的 如果TypeName(ChainsDC(j,0)=“String”**则** 转到结束循环 其他: 对于i=0至RscSct …在这里做令人惊奇的事情(无循环) 接下来我 **如果结束** 结束循环: 下一个j'

在嵌套的Excel VBA For…Next循环中,父级Next无法找到其For j=0到SpreadCount的 如果TypeName(ChainsDC(j,0)=“String”'测试错误 转到结束循环 其他: 对于i=0至RscSct …在这里做令人惊奇的事情(无循环) 接下来我 结束循环: 下一个问题是你的IF语句。你需要添加一个Then和一个End IF: For j = 0 to SpreadCount If TypeName(ChainsDC(j,0) = "String" 'testing for an error Goto EndLoop Else: For i = 0 to RscSct ...do amazing things here (no loops) Next i EndLoop: Next j '<<<PROBLEM j=0到SpreadCount的 如果TypeName(ChainsDC(j,0)=“String”**则** 转到结束循环 其他: 对于i=0至RscSct …在这里做令人惊奇的事情(无循环) 接下来我 **如果结束** 结束循环: 下一个j',vba,Vba,您的其他:可能是问题所在,如果j=0到SpreadCount,则缺少结束 For j = 0 to SpreadCount If TypeName(ChainsDC(j,0) = "String" **Then** Goto EndLoop Else: For i = 0 to RscSct ...do amazing things here (no loops) Next i **End If**

您的
其他:
可能是问题所在,如果j=0到SpreadCount,则缺少
结束
For j = 0 to SpreadCount
    If TypeName(ChainsDC(j,0) = "String" **Then**
        Goto EndLoop
    Else:
        For i = 0 to RscSct
            ...do amazing things here (no loops)
        Next i
    **End If**
EndLoop:
Next j '<<<PROBLEM
如果TypeName(ChainsDC(j,0))“String”,那么 对于i=0至RscSct …在这里做令人惊奇的事情(无循环) 接下来我 如果结束 下一个j
正如Remou指出的,您应该去掉Goto并测试您想要测试的内容,即它不是字符串


通常情况下,除非行中有另一段可执行代码,否则不应该在else后面加冒号。即使这样…

您的代码和逻辑也存在一些问题

For j = 0 to SpreadCount
    If TypeName(ChainsDC(j,0)) <> "String" Then
        For i = 0 to RscSct
            ...do amazing things here (no loops)
        Next i
    End If
Next j
j=0到SpreadCount的

如果TypeName(链式SDC(j,0)=“String”测试是否出错
转到结束循环
其他:
对于i=0至RscSct
…在这里做令人惊奇的事情(无循环)
接下来我
结束循环:

下一个j’VBA编辑器不会自动缩进。否则,您会看到“下一个j”行与“下一个i”处于同一级别,因此告诉您问题在于缺少“如果结束”,就像@PowerUser在他的回答中说的。这段代码至少有四个语法错误。在这一点上,为您使用的每一个关键字读取VBA帮助文件可能会有所帮助。+1我认为@Montecarologenerator不费吹灰之力就可以避免goto。实际上,您可以不使用任何内容替换goto并获得same效果!@PowerUser:你应该在
Else
之后删除
。代码有很多错误,只有then和End If:)你看到它有什么问题?它是一个标签而不是一个
Else
。对不起,这是我在复制到StackOverflow时的一个输入错误。为什么你不复制并粘贴实际的问题代码到你的问题中。这将为试图回答问题的人解决很多WTF。
For j = 0 to SpreadCount
    If TypeName(ChainsDC(j,0) = "String" 'testing for an error
        Goto EndLoop
    Else:
        For i = 0 to RscSct
            ...do amazing things here (no loops)
        Next i
EndLoop:
Next j '<<<PROBLEM
For i = 0 To SpreadCount
    If TypeName(ChainsDC(i, 0)) <> "String" Then
        For j = 0 To RscSct
            '...do amazing things here
        Next
    End If
Next