PDA

View Full Version : [SOLVED] For Loop for 2 Range



vmjamshad
04-24-2018, 01:56 AM
Hi,
Is this possible in VBA?

For a = 1 To 10 and 15 To 20

Next a

gmayor
04-24-2018, 03:44 AM
Not quite, however



For a = 1 To 20
If a < 11 Or a > 14 Then
'do stuff
End If
Next a

offthelip
04-24-2018, 06:42 AM
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

vmjamshad
04-24-2018, 08:10 PM
Thank u both