开发者

Iterations In From Loop

开发者 https://www.devze.com 2023-01-15 23:27 出处:网络
is there a way to say in vba something like: from x = 1 to 开发者_Python百科100, by 10 so that the x\'s are 1, 10, 20, 30, etc. to 100?You can use STEP:

is there a way to say in vba something like:

from x = 1 to 开发者_Python百科100, by 10

so that the x's are 1, 10, 20, 30, etc. to 100?


You can use STEP:

for x = 0 to 100 step 10

next x

This will take you through 0, 10, 20... 100

Since you want to start at 1 and go 1, 10, 20... 100, here is a slight modification

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


For y = 0 To 10
    If y = 0 Then x = 1 Else x = 10 * y

    ' do stuff with x

Next y
0

精彩评论

暂无评论...
验证码 换一张
取 消