for i=1 to 10
if cells(i,3)=cells(i,4) then
a=i+1
else a=i+2
next
我想达到的效果是循环执行10次,每次执行都先做判断,根据判断结果执行下面的操作,但这么写会提示for 没有next,求解答,非常感谢!
第1个回答 2021-02-25
你的if语句,缺少End if
if语句如果没有换行,则不需要End if
例如:
if cells(i,3)=cells(i,4) then a=i+1
IF语句如果有换行,则必须要有End if
例如:
if cells(i,3)=cells(i,4) then
a=i+1
End if
例如:
if cells(i,3)=cells(i,4) then
a=i+1
Else
a=i+2
End if
第2个回答 2021-02-25
for i=1 to 10
a=i+iif(cells(i,3)=cells(i,4),1,2)
next
a=i+iif(cells(i,3)=cells(i,4),1,2)
next