Looping

G

Guest

I'm trying to create a loop that will stop at the first blank line, then skip
4 lines and start the loop again. So far the first loop works great. I have
trouble with it trying to restart the loop after it skips four lines. Can
anyone Help!!!!!! This is what i have for the first loop.


Sub CalculateVariance()

Dim i As Integer
i = 11

Do Until IsEmpty(Cells(i, 9))

Cells(i, 17).Formula = "=rc[-8]-rc[-4]"
Cells(i, 18).Formula = "=rc[-8]-rc[-4]"
Cells(i, 19).Formula = "=rc[-8]-rc[-4]"

i = i + 1
Loop
 
G

Guest

Try this:

Sub CalculateVariance()

Dim i As Integer
i = 11

Do Until IsEmpty(Cells(i, 9))

Cells(i, 17).Formula = "=rc[-8]-rc[-4]"
Cells(i, 18).Formula = "=rc[-8]-rc[-4]"
Cells(i, 19).Formula = "=rc[-8]-rc[-4]"

i = i + 1
Loop

i = i + 4

Do Until IsEmpty(Cells(i, 9))

Cells(i, 17).Formula = "=rc[-8]-rc[-4]"
Cells(i, 18).Formula = "=rc[-8]-rc[-4]"
Cells(i, 19).Formula = "=rc[-8]-rc[-4]"

i = i + 1

Loop
 
G

Guest

Christopher-

THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

It worked like a charm.... You're the best man


ChristopherTri said:
Try this:

Sub CalculateVariance()

Dim i As Integer
i = 11

Do Until IsEmpty(Cells(i, 9))

Cells(i, 17).Formula = "=rc[-8]-rc[-4]"
Cells(i, 18).Formula = "=rc[-8]-rc[-4]"
Cells(i, 19).Formula = "=rc[-8]-rc[-4]"

i = i + 1
Loop

i = i + 4

Do Until IsEmpty(Cells(i, 9))

Cells(i, 17).Formula = "=rc[-8]-rc[-4]"
Cells(i, 18).Formula = "=rc[-8]-rc[-4]"
Cells(i, 19).Formula = "=rc[-8]-rc[-4]"

i = i + 1

Loop

David T said:
I'm trying to create a loop that will stop at the first blank line, then skip
4 lines and start the loop again. So far the first loop works great. I have
trouble with it trying to restart the loop after it skips four lines. Can
anyone Help!!!!!! This is what i have for the first loop.


Sub CalculateVariance()

Dim i As Integer
i = 11

Do Until IsEmpty(Cells(i, 9))

Cells(i, 17).Formula = "=rc[-8]-rc[-4]"
Cells(i, 18).Formula = "=rc[-8]-rc[-4]"
Cells(i, 19).Formula = "=rc[-8]-rc[-4]"

i = i + 1
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top