VBA一直做到循环调节?

sub*_*bha 2 excel vba excel-vba

我必须使用'DO UNTIL'条件,如果满足某些条件,我会给出一个

这里的例子.

对于工作表中的单元格(9,3),我必须检查单元格(9,3).value是否为

空或其"0".如果是这样,我必须询问用户的输入,它应该

介于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
Run Code Online (Sandbox Code Playgroud)

但它没有做到直到它跳过所有步骤.请帮忙.

Dio*_*aim 5

代码的问题是每次条件(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.
Run Code Online (Sandbox Code Playgroud)

您需要做的就是使用三个条件,例如:

Do Until IsNumeric(AA) And 1 < AA And AA < 100
Run Code Online (Sandbox Code Playgroud)