有没有办法在vba中说:
from x = 1 to 100, by 10
使x为1,10,20,30等等至100?
答案 0 :(得分:6)
您可以使用 STEP :
for x = 0 to 100 step 10
next x
这将引导您完成0, 10, 20... 100
由于您希望从1
开始并转到1, 10, 20... 100
,因此稍作修改
for x = 0 to 100 step 10
if x = 0 then
y = 1
else
y = x
end if
'// use y in all calculations downstream instead of x
next x
答案 1 :(得分:0)
For y = 0 To 10
If y = 0 Then x = 1 Else x = 10 * y
' do stuff with x
Next y