For-Next-Loop

  • Think i already know the answer to this, but can you use letters instead of numbers in a FOR-Next-LOOP? Tried to get it to work a couple of different ways but couldn't get it, thought i would ask.


    FOR I = A to J
    CODE'
    Next I


    Thnak you

    [SIZE="6"][FONT="Comic Sans MS"]Brain G.[/FONT][/SIZE] :loopain:

  • Re: For-Next-Loop


    Hi,


    If you want letters you will need to modify the syntax.
    Using double quotes fails and sinlge quotes act as comments.
    [vba]Sub x()
    Dim i
    For i = Asc("A") To Asc("J")
    Debug.Print Chr(i)
    Next
    End Sub[/vba]

    [h4]Cheers
    Andy
    [/h4]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!