VBA编译错误'没有' [英] VBA Compile Error 'Wend Without While'

查看:140
本文介绍了VBA编译错误'没有'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Excel中的VBA宏已经运行了一段时间。我已经在改变这些循环已经工作,突然代码没有编译:


编译错误:Wend without While


我已经尝试改为Do While ... Loop循环,但是我得到了相当的


编译错误:循环没有执行


这是我的代码的结构:

 '这个循环很好
虽然'(代码用于评估)
'代码以循环运行
(w)

虽然'(更多的eval代码)
'代码
虽然'(eval代码)
'代码
Wend'< - 是编译错误发生的地方
'code
虽然'(eval代码)
'代码
Wend
'代码
Wend

有谁有任何想法可能是什么问题? (奖金:代码的缩进实际上是否重要?)

解决方案

此消息通常没有表示未终止的 IF



某处可能会出现 IF ,而不匹配 End If



(这种错误消息有点恼人,因为它隐藏了真正的错误)


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:

Compile error: Wend without While

I have tried changing to Do While...Loop loops, but I got the equivalent

Compile error: Loop without Do

Here is the structure of my code:

'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?)

解决方案

This message Wend without While usually indicates an un-terminated IF

Somewhere there may be an IF without the matching End If

(This kind of error message is a bit annoying since it hides the true error)

这篇关于VBA编译错误'没有'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆