Consulting

Results 1 to 4 of 4

Thread: For Loop for 2 Range

  1. #1

    For Loop for 2 Range

    Hi,
    Is this possible in VBA?
    For a = 1 To 10 and 15 To 20
    
    Next a

  2. #2
    Not quite, however

    For a = 1 To 20
        If a < 11 Or a > 14 Then
           'do stuff
        End If
    Next a
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    VBAX Expert
    Joined
    May 2016
    Posts
    604
    Location
    Another possible way that might do what you want:

    for a = 1 to 10
       for b= 15 to 20 step 1
    '    do stuff with a and b indices 
       next b
    next a

  4. #4
    Thank u both

Posting Permissions

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