#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 70
Default Looping

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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default Looping

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" wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 70
Default Looping

Christopher-

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

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


"ChristopherTri" wrote:

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" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping Question MWS Excel Discussion (Misc queries) 1 June 5th 06 07:23 PM
Looping between sheets picking up values on the way bungie Excel Worksheet Functions 3 March 5th 06 07:22 AM
Looping in VB with cell ranges Freeman Excel Worksheet Functions 2 January 22nd 06 12:14 PM
looping question luke New Users to Excel 4 June 3rd 05 01:19 PM
Looping macros using VB code accessuser1308 Excel Discussion (Misc queries) 2 March 9th 05 11:11 PM


All times are GMT +1. The time now is 05:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"