VBA编译错误&Wend Without While' [英] VBA Compile Error 'Wend Without While'
问题描述
我在excel中有一个VBA宏,已经运行了一段时间.我一直在使用这些循环进行更改,并且突然代码无法编译:
I have a VBA macro in excel that has run fine for a while. I've been making changes with these loops already working and suddenly the code is not compiling:
编译错误:不使用While的情况下
Compile error: Wend without While
我尝试更改为Do While ... Loop循环,但是我得到了等效的结果
I have tried changing to Do While...Loop loops, but I got the equivalent
编译错误:不执行循环
Compile error: Loop without Do
这是我的代码的结构:
'This loop is fine
While '(code for evaluation)
'code to run in loop
Wend
While '(more eval code)
'code
While '(eval code)
'code
Wend '<--This is where the compile error occurs
'code
While '(eval code)
'code
Wend
'code
Wend
有人知道这可能是什么问题吗?(奖金:代码缩进真的重要吗?)
Does anyone have any idea what could be the issue? (Bonus: Does the indentation of code actually matter?)
推荐答案
此消息无时无休通常表示未终止的 IF
This message Wend without While usually indicates an un-terminated IF
在某些地方可能存在 IF 而没有匹配的 End If
Somewhere there may be an IF without the matching End If
(这种错误消息有点令人讨厌,因为它隐藏了真正的错误)
这篇关于VBA编译错误&Wend Without While&#39;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!