.
.
Last edited by Tdude; 08-28-2014 at 10:43 AM.
Dear All,
a quick one....
I am dealing with a nested for/next loop but I actually need both i and j to change at the same time and not one at the time.
something like "For i = 1 To 30 and j=0 to 87" or "For i = 1 To 30, j=0 to 87"
I'm sure it is easier than it looks but just can't find a way.
Do you have any suggestions, please?
Thanks in advance
the sample code is the following
[VBA]
Sub Trial()
For i = 1 To 30
For j = 0 To 87 Step 3
With Range("A1")
Set myRange = Range(.Offset(1, i + j), .Offset(1, i + j).End(xlDown))
End With
Next j
Next i
End Sub
[/VBA]
J = -3 For 1 = 1 to 30 J = J + 3 blah blah Next I
I expect the student to do their homework and find all the errrors I leeve in.
Please take the time to read the Forum FAQ
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
mathematically identical results
But mine's faster :LOL
I expect the student to do their homework and find all the errrors I leeve in.
Please take the time to read the Forum FAQ
Sorry, it was the line
which I was suggesting that you really meantFor 1 = 1 To 30
in your code that I was remarking upon, I just changed the way j was set as it seemed more intuitive (at least to me it did).For i = 1 To 30
____________________________________________
Nihil simul inventum est et perfectum
Abusus non tollit usum
Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
James Thurber
Thank you both for your help !!
Yes, I meant i =1 to 30
My finger always reaches first for the 1 when I use lower case I
The way Tdude worded his Q made that J = J +3 jump into my (weak, medically abused, and pain filled) head. After I had it in print I looked askance at it for a while thinking.
I came to the conclusion that is is actually a bit faster than using a multiplier on the outer loop counter.
I'm so happy now! I saved 30 seconds/petaflop!
I expect the student to do their homework and find all the errrors I leeve in.
Please take the time to read the Forum FAQ