loop and end loop

B

Bob W

Can anyone help. I have a 15 thousand line spread sheet that requires me to
take certain information and bring it up to the same line as the first
instance of a product. I have written a macro that works fine. However I am
trying to loop it to do the whole sheet. I can 't seem to make the loop work
even with the help function. The code is as follows:
do loop

ActiveCell.Offset(0, 4).Range("A1").Select
Selection.Copy
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, -2).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(0, -2).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(0, 3).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, -5).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 6).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, -5).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 6).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(1, -5).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-1, 6).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(2, -8).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-2, 9).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(2, -8).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-2, 9).Range("A1").Select
ActiveSheet.Paste
ActiveCell.Offset(2, -8).Range("A1").Select
Application.CutCopyMode = False
Selection.Copy
ActiveCell.Offset(-2, 9).Range("A1").Select
ActiveSheet.Paste
ActiveWindow.ScrollColumn = 7
ActiveWindow.ScrollColumn = 6
ActiveWindow.ScrollColumn = 5
ActiveWindow.ScrollColumn = 4
ActiveWindow.ScrollColumn = 3
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
ActiveCell.Offset(1, 0).Rows("1:1").EntireRow.Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlUp
Selection.Delete Shift:=xlUp
ActiveCell.Select
Loop Until ActiveCell(A1409)

It complains that I am not using a do, but I think I am, it is there, it
just doesn't seem to think it is.

Any help would be greatly appriciated.

Thanks
 
R

RWN

The "Loop" command should appear at the end of the routine.
Your condition s/b at the beginning of the routine.

DO UNTIL <some condition (which will be set within the routine) is met> or
DO WHILE <some condition that is true-exits when the condition becomes false>
code
code
etc
LOOP

When Basic hits the LOOP it returns to the top of the loop and checks the condition and
performs the routine again UNLESS whatever condition is met and-If met- jumps to the
statement following the LOOP statement.
Ensure that whatever condition is stated will be met in the routine or you'll be waiting
a long time for the loop to end!

If you think that the condition is not being met use a CTRL-Break to stop the routine.
 

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