美文网首页
Excel VBA基础教程——循环

Excel VBA基础教程——循环

作者: 林万程 | 来源:发表于2017-03-01 20:49 被阅读51次

    Sub 过程名()

    i = 1
    s = 0 '初始值为0可略
    
    While i <= 100
        s = s + i
        i = i + 1
    Wend
    
    Do While i <= 100
        s = s + i
        i = i + 1
    Loop
    
    Do '第一次无条件执行
        s = s + i
        i = i + 1
    Loop While i <= 100
    
    Do
        s = s + i
        i = i + 1
    Loop Until i > 100
    
    Do
        s = s + i
        i = i + 1
        If i > 100 Then Exit Do
    Loop
    
    For i = 1 To 100
        s = s + i
    Next
    
    For Each sh In Sheets
        sh.[A1] = sh.Name
    Next
    

    End Sub

    相关文章

      网友评论

          本文标题:Excel VBA基础教程——循环

          本文链接:https://www.haomeiwen.com/subject/yaucgttx.html