VBA做循环调理?

如果某些条件得到满足,我必须使用“DO UNTIL”条件

这里的例子。

对于单元格(9,3),我必须检查单元格(9,3).value是否是

空或其“0”。 如果是这样,我不得不要求用户的input,它应该

介于1到100之间。我写这样的代码

DO until 1<AA<100 if cells(9,3).value="" or cells(9,3).value="o" then AA=InputBox("cells(9,3).value", "Enter only values as Numeric ", "give the value Here") else AA= cells(9,3).value end if loop 

但是它没有做,直到它跳过所有的步骤。 请帮忙。

代码的问题是每次条件(1 <AA <100)都会返回true:

代码解释将是这样的

 C1 = (1 < AA) C2 = C1 < 100 So, if: AA > 1 Then C1 = 1 (True as VBA don't use strong types operators) And if: AA < 1 Then C1 = 0 (False as VBA don't use strong types operators) Annnnd if: AA is text, then C1 = 1 (Every non numeric character is bigger than an integer for VBA) Then: C1 = 1 or 0 or 1 The second condition will be: C2 = C1 < 100 then if C1 = 0 or if C1 = 1 both are less than 100, it causes that C2 will aways be true. 

所有你需要做的就是使用三个条件,如:

 Do Until IsNumeric(AA) And 1 < AA And AA < 100