循环中的迭代

use*_*667 1 iteration vba

有没有办法在vba中说:

from x = 1 to 100, by 10
Run Code Online (Sandbox Code Playgroud)

所以x是1,10,20,30等等到100?

Raj*_*ore 6

你可以使用STEP:

for x = 0 to 100 step 10

next x
Run Code Online (Sandbox Code Playgroud)

这将带你通过 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
Run Code Online (Sandbox Code Playgroud)