Results 1 to 4 of 4

Thread: Loop with 2 variabiles
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    New Member
    Join Date
    Mar 2018
    Posts
    44
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Loop with 2 variabiles

    Hello to everyone

    Pleas help me

    I use this vba code to create a loop
    Sub Loop()
    For i = 1 To 250 Step 6
    For j= 1 To 60
    Cells(i, 1) = j
    Next j
    Next i

    End Sub

    The result is
    60
    60
    60
    60

    I want to know which is vba code to obtain

    1
    2
    3
    4


    Thank's
    Last edited by IoanZ; Aug 4th, 2019 at 04:25 AM.

  2. #2
    Board Regular MrIfOnly's Avatar
    Join Date
    Nov 2016
    Location
    Wisconsin
    Posts
    489
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop with 2 variabiles

    No need to loop j, just increment it.
    Code:
    j = j + 1
    As an exercise try putting the above line before, then after the Cells(i, 1) = j line.

    Regards,

    CJ
    *************************************************
    Rate Schedule:

    • Answers: $1
    • Correct Answers: $2
    • Dumb looks are still free.

    *************************************************

    Want to make your listbox column widths adjustable? Take a look at this YouTube video and this sample file on RoryA's informative website: Tips and tricks | Excel Matters

  3. #3
    New Member
    Join Date
    Mar 2018
    Posts
    44
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop with 2 variabiles

    Quote Originally Posted by MrIfOnly View Post
    No need to loop j, just increment it.
    Code:
    j = j + 1
    As an exercise try putting the above line before, then after the Cells(i, 1) = j line.

    Regards,

    CJ

    Thank's a lot

  4. #4
    Board Regular MrIfOnly's Avatar
    Join Date
    Nov 2016
    Location
    Wisconsin
    Posts
    489
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Loop with 2 variabiles

    You're welcome.
    *************************************************
    Rate Schedule:

    • Answers: $1
    • Correct Answers: $2
    • Dumb looks are still free.

    *************************************************

    Want to make your listbox column widths adjustable? Take a look at this YouTube video and this sample file on RoryA's informative website: Tips and tricks | Excel Matters

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •